Reputation: 3451
There are a lot of answers out there for browser caching but most are about either turning caching on or off or requesting using a different url for some static asset like js or images.
When the user takes that action, I want to invalidate the cache and get a new version from the server.
Is there a way to clear the browsers local cache without changing the url. So, /tasks is cached until next year. I want to invalidate that and force future requests to /tasks to get new data and a new expires header.
Would I be better off not allowing browser caching and cache the requests/data on the server instead?
Another similar question: Forcing AJAX request to revalidate cache with server, without reloading completely
Upvotes: 1
Views: 2245
Reputation: 2083
foreach request with cache: false
jquery will add a timestamp as a get paramater, so the request is unique and won't be cached
$.ajax({
url:"example.php"
cache:false
});
referring to the jquery docs: cache (default: true, false for dataType 'script' and 'jsonp') Type: Boolean If set to false, it will force requested pages not to be cached by the browser. Note: Setting cache to false will only work correctly with HEAD and GET requests. It works by appending "_={timestamp}" to the GET parameters. The parameter is not needed for other types of requests, except in IE8 when a POST is made to a URL that has already been requested by a GET.
Upvotes: -1