When I use ajax to query a database, I only query the database for the first time. I will not submit any more requests to the server for processing.
The cache tag in the page header does not work.
<Meta http-equiv = "Pragma" content = "no-Cache">
<Meta http-equiv = "cache-control" content = "no-Cache">
<Meta http-equiv = "expires" content = "0">
Solution:
1: add the timestamp var url = URL + "& timestamp =" + new date (). gettime ();
2: Add random number var url = URL + "& Ran =" + math. Random (); 1. Prevent reading data from the cache
When Ajax calls the background page, it first determines whether the page exists in the cache. If yes, it takes the value from the cache. The purpose of adding a random number is obvious.
2. Security also plays a role
3: add request. setRequestHeader ("If-modified-since", "0") before request. Send ");
4: Add response. setheader ("cache-control", "No-Cache") before output. Print in the background; clear the cache
Ajax cache Problems