I would like to enable caching of an ajax response in javascript/browser.
From the jquery.ajax docs:
By default, requests are always issued, but the browser may serve
results out of its cache. To disallow use of the cached results, set
cache to false. To cause the request to report failure if the asset
has not been modified since the last request, set ifModified to true.
However, neither of these address forcing caching.
Motivation:
I want to put $.ajax({...})
calls in my initialisation functions, some of which request the same url. Sometimes I need to call one of these initialisation functions, sometimes I call several.
So, I want to minimise the requests to the server if that particular url has already been loaded.
I could roll my own solution (with some difficulty!), but I would like to know if there is a standard way of doing this.