[a] Sometimes we need to enable or disable caching of ajax requests for browsers. can be done using the flag under the flag. cache: true
the code:
global_xhrAbort = $.ajax({ cache: true, type: "GET", timeout: 30000, async: false, url: finalurl, data: null, contentType: "application/x-www-form-urlencoded; charset=UTF-8", dataType: "json", complete: function () { }, success: function (data) { console.log('picked from server koimoi: success'); Page_topstoriesJson = GetJSONifNeeded(data); ; HTMLSTORAGE_SET('landingpage', GetJSONstringfyifNeeded(data));
JQuery AJAX Cupcake Documentation: (default: true, false for dataType 'script' and 'jsonp') Type: Boolean If set to false, this will cause the requested pages not to be cached by the browser. Note. Setting the cache to false will only work with HEAD and GET requests. It works by adding "_ = {timestamp}" to the GET parameters. The parameter is not needed for other types of requests, with the exception of IE8, when a POST is created with a URL that has already been requested by GET.
[b] Remember: Ctrl + R on chrome always downloads new data from the server, even if it is cached. Open the page in a new window to see the test results.
source share