Web server on WiFi Shield R3 with firmware 1.1.0 unresponsive after some hours

I've read tens of posts in different forums about this subject.
In many times the solution was to upgrade the shield to the latest firmware.
What can I do with this issue, using the latest firmware? I have the typical issue of instability. After a couple of hours, depending of how many requests are made, the shield becomes unresponsive.

The project is a simple REST web server.
The purpose is to respond with JSON if the request is correct REST otherwise a HTTP 400 error.
I post a simplified version of it, so you can see the way I've written the program (apart from the setup(), here is the loop()):

void loop() {  
  WiFiClient client = server.available();
  if (client)
  {    
    if (client.connected())
    {
      Serial.println("New client:");
      
      String response = client.readString();
      Serial.println(response);
      
      // request finished, send response
      String command = "";
      int index = response.indexOf('\n');
      if (index > 0)
      {
        command = response.substring(0, index - 1);
      }
      
      if (command.length() > 0) 
      {
        // Operations: do something

        client.println("HTTP/1.1 200 OK\nContent-Type: application/json");
        client.println("Content-Length:19\nConnection: close\n");
        client.println("{ \"result\":\"OK\" }\n");

        // close the connection:
        delay(20);
        client.stop();
  
        Serial.println("Client disconnected");        
        return;
      }

      client.println("HTTP/1.1 400 OK\nContent-Type: text/html");
      client.println("Connection: close\n");
      client.println("HTTP 400");

      // close the connection:
      delay(20);
      client.stop();
  
      Serial.println("Client disconnected");
    }
  }
}

Any suggestions are really appreciated!
Greetings

Please guys...
I can add that I've made many different versions of the program, for example using client.available(), using a while loop as many examples/tutorials suggest and so on.
Unfortunately none of the different versions have given an improvement what so ever.

It seems the solution is to detect the connection and make a soft reset accordingly to the server status.
It means that the first thing to do in loop() is this:

  // do a soft-reset in case of lost connection
  uint8_t serverStatus = server.status();
  if (serverStatus == WL_IDLE_STATUS || serverStatus == WL_CONNECT_FAILED)
  {
    asm volatile ("  jmp 0");
    return;
  }

The soft reset is necessary. In case of unresponsiveness, the server won't react if you try to recover it.

But no, it's not the right solution.
Even trying with another soft reset alternative, such as:

void(* resetFunc) (void) = 0; //declare reset function @ address 0

the soft reset doesn't really make a clean restart of the Wifi server.
it works once, maybe twice, then the Wifi becomes unresponsive anyway.

I hope there's a better solution - not a work-around like mine.