sd card webserver refresh issue

I'm making progresses with my webserver.
My index.htm is located on the microSD card and it works fine even jQuery/AJAX but I have a little problem.
If I reload the page I can't see my page anymore. I need to power off the arduino and power on again.
It doesn't happens if I write my html code directly in the sketch.

Is it a known problem?

Thanks

Is it a known problem?

Yes, it's a well known problem that people ask questions about their code without posting it.

LOL, I was just asking if it is a known problem that's why I did not attached any code even because it's a bit long. :smiley:
Anyway, now I realized it isn't a known problem and this is my sketch:

#include <SPI.h>
#include <Ethernet.h>
#include <SD.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

IPAddress ip(192, 168, 1, 4);

EthernetServer server(80); 

File fileToSend;

String msg = ""; 

void printCssHeader(EthernetClient client){
  client.println("HTTP/1.1 200 OK");
  client.println("Content-Type: text/css");
  client.println("Connection: close");
  client.println();
}
void printHtmlHeader(EthernetClient client){
  client.println("HTTP/1.1 200 OK");
  client.println("Content-Type: text/html");
  client.println("Connection: close");
  client.println();
}


void setup()
{
    Ethernet.begin(mac, ip);  
    server.begin();           

    Serial.begin(9600);       
    
    
    if (!SD.begin(4)) { return; }
    
    
}

void loop()
{
    msg = "";
    
    EthernetClient client = server.available();  

    if (client) { 
        boolean currentLineIsBlank = true;
        
        while (client.connected()) { 
          
            if (client.available()) {   
                        
                char c = client.read(); 
		
                msg += c; 
		                
                
                if (c == '\n' && currentLineIsBlank) {
                  Serial.println(msg);
                  
                  //handle the browser request
                  if(msg.indexOf("favicon.ico")>-1){
                    //NOPE
                    Serial.println("No favicon today! :) ");
                  }
                  else if(msg.indexOf("layout.css")>-1){
                //////TO DO USE A REAL .CSS FILE
                    printCssHeader(client);
                    client.println("body{background-color: #C0FFFF;}");
                    
                  }
                  else if(msg.indexOf("lightSensor")>-1){
                    client.println("sensor checked!");
                  }
                  else if(msg.indexOf("tempHumSensor")>-1){
                    client.println("sensor checked!");
                  }
                  
                  else if(msg.indexOf("index.htm")>-1){
                 Serial.println("index");
                    printHtmlHeader(client);
                    
                    fileToSend = SD.open("index.htm");                   
                    
                    if (fileToSend) {
                      Serial.println("file is ok");
                      while(fileToSend.available()) {
                        client.write(fileToSend.read()); 
                      }
                      fileToSend.close();
                    }

                  }
                                                               
                  break;                                  
                    
                }
               
                if (c == '\n') {
                  
                    currentLineIsBlank = true;
                } 
                else if (c != '\r') {
                   
                    currentLineIsBlank = false;
                }               
                
                
            } 
            
        }   
        delay(1);      
        client.stop(); 
    }
}