Don't send continuously the measurements

I have made sketch with arduino uno and esp8266 in which i send measures of HC-SR04 to a website. While constantly sending every detail counts, several times makes pauses for 5:25 or 5:45 minutes. Generally it has been working normally for two months, just sometimes making these few short pauses. What can happen to that? My code is:

#include <SoftwareSerial.h>
SoftwareSerial espSerial =  SoftwareSerial(2,3);  

//Wifi network SSID password
String ssid="ffffff";
String password ="*******";

boolean DEBUG=true;

int echoPin = 12; 
int trigPin = 13; 

long duration, distance; 
int alarm;

String alarms;

String data;
String server = "www.example.com"; // Send data to this site

String uri = "/add2.php";

int error = 0;
int cancel = 0;

void showResponse(int waitTime){
    long t=millis();
    char c;
    while (t+waitTime>millis()){
      if (espSerial.available()){
        c=espSerial.read();
        if (DEBUG) Serial.print(c);
      }
    }
                   
}

boolean websiteWrite(long value1, int value2){ 
  if (value2 == 0){
    alarms = "OFF";
  }else{
    alarms = "ON";
  }
  
  data = "distance=" + String(value1) + "&alarm=" + alarms;
  
  espSerial.println("AT+CIPSTART=\"TCP\",\"" + server + "\",80");//start a TCP connection.
  
  if( espSerial.find("OK")) {
  
  Serial.println("TCP connection ready"); cancel = 0;
  
  }
  else{
    cancel = cancel + 1;  Serial.println("cancel="); Serial.println(cancel);
  }
  delay(1000);
  
  String postRequest =
  
  "POST " + uri + " HTTP/1.0\r\n" +
  
  "Host: " + server + "\r\n" +
  
  "Accept: *" + "/" + "*\r\n" +
  
  "Content-Length: " + data.length() + "\r\n" +
  
  "Content-Type: application/x-www-form-urlencoded\r\n" +
  
  "\r\n" + data;
  
  String sendCmd = "AT+CIPSEND=";//determine the number of caracters to be sent.
  
  espSerial.print(sendCmd);
  
  espSerial.println(postRequest.length() );
  
  delay(500);
  
  if(espSerial.find(">")) { Serial.println("Sending.."); espSerial.print(postRequest);
  
  if( espSerial.find("SEND OK")) { Serial.println("Packet sent");
  
  while (espSerial.available()) {
  
  String tmpResp = espSerial.readString();
  
  Serial.println(tmpResp);
  
  }
  
  // close the connection
  
  espSerial.println("AT+CIPCLOSE");
  
  }
    error = 0;
  }else{
    error = error + 1;
    Serial.println("error=");
    Serial.println(error);
    
  }
  
  if(cancel >=15 || error >= 15){software_Reset() ;}
  
}

void setup() {
  delay(150000); 
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  
  DEBUG=true;           
  Serial.begin(9600); 
  
  espSerial.begin(9600);  
  
  //espSerial.println("AT+RST");         
  //showResponse(1000);
  
  //espSerial.println("AT+UART_DEF=9600,8,1,0,0");    
  //showResponse(1000);
  
  espSerial.println("AT+CWMODE=1");   
  showResponse(1000);

  espSerial.println("AT+CWJAP=\""+ssid+"\",\""+password+"\"");  
  showResponse(5000);

  if (DEBUG)  Serial.println("Setup completed");  
}

void loop() {

  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = duration/58.2;
  
  if (distance<=8){
    alarm=1;
  }else{
    alarm=0;
  }
  
      if (isnan(distance)) {
        if (DEBUG) Serial.println("Failed of calculation the distance");
      }
      else {
          if (DEBUG)  Serial.println("Distance="+String(distance)+" cm");
           websiteWrite(distance,alarm);                                      // Write values to website
      }
  
    
  //Needs 60 sec delay between updates    
  delay(60000);    
}

void software_Reset() // Restarts program from beginning but does not reset the peripherals and registers
{
asm volatile ("  jmp 0");  
}

Are you logging the Serial output? If you do so with timestamps you could check whether the pauses are associated with the error handling output. If it's not possible for you to do that then you could write some data to EEPROM to use for forensics.

Are you aware that the use of String is strongly recommended against, and is known to cause unstable operation due to memory fragmentation?