When using AJAX for Web development, there are often some puzzling questions.
For example, the first time the AJAX request is normal, and the second time why it is not normal, and often appear in the first request the same result.
In fact, this is because the first time the AJAX request is actually sent to the server, and the second time is not really sent to the server, but from the IE cache read.
So how do we solve this problem?
The simple way to do this is to make the URL of the AJAX request different every time.
Workaround: Add a random number after the URL of the AJAX request:? Ram=math.random ()
Example: The URL to be requested is "ajax.aspx"
Then instead: "ajax.aspx?ram=" + math.random ();
This completely avoids errors caused by Ajax reading from the cache.
The second kind of clearing cache:
Response.ExpiresAbsolute = DateTime.Now.AddDays (-1);
response.expires=0;
Response.cachecontrol= "No-cache";
Problems with Ajax clearing cache