Reputation: 148524
jQuery :
*cacheBoolean
Default: true, false for dataType 'script' and 'jsonp'
If set to false, it will force requested pages not to be cached by the browser.
Setting cache to false also appends a query string parameter, "_=[TIMESTAMP]", to the URL.*
my question :
cached by the browser ???
if i have an ASHX handler which returns me :
'<div>lalala</div>'
will this be saved on the browser temporary Internet Files ?
I dont think so....
so where does it saves it ?
Upvotes: 0
Views: 1223
Reputation: 10548
jQuery itself does not perform any caching of the AJAX response. Setting cache: false
serves only to trick the browser into ignoring its own cache by adding a timestamp to the requested URL.
For example, running:
$.ajax('/ajax_handler.php', { cache: false });
Will result in a request for /ajax_handler.php?_=1323308900002
.
Any subsequent request will include a newer timestamp at the end, which will cause the browser to ignore cached versions of the file and request a new copy.
So, all setting cache: true
does is instruct jQuery to not append this cache-busting timestamp (the current default anyway), allowing the browser to cache the file as it normally would*.
In summary: any caching that happens is just regular browser caching, the files will be stored however the browser typically stores its cache.
* Note that "as it normally would" might mean not caching the file! jQuery doesn't do anything to ensure caching, it's up to the browser. If the page sends certain Cache-control
or pragma
headers, it simply won't be cached. It would arguably make more sense for jQuery to have a "cacheBust" setting that's the inverse of cache
, because that's all jQuery can do: attempt to prevent caching.
Upvotes: 1
Reputation: 76880
i think that "cached by the browser" means that if the browser (IE more than others...) intercept the same call twice, never calls the server and just returns whatever the server returned the last time. But if you clear the cache it goes away
Upvotes: 0