Preventing browser from caching AJAX requests
In case of GET requests, browsers cache these requests and when the request is invoked again they do not send the request to the server and instead serve it from the cache.
This recipe will explain how to force browsers to send the request to a server instead of serving it from the cache.
How to do it...
While sending an AJAX request use the
cache
option to force no caching by the browser. Setting thecache
option tofalse
does not let the browser cache any AJAX requests and the data is loaded from the server each time the request is made.$.ajax({ url : 'someurl.php', cache: false, success: function(data) { //do something with received data } });
How it works...
On an AJAX request, the browser checks if a request to that URL is already in the browser cache or not. If it is found in the cache, no request to the server is sent and response from the cache is served.
jQuery provides a cache option that can be used to override this browser...