styks
styks

Reputation: 3451

Selectively Force Browser Cache to Clear Ajax Request

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.

Another similar question: Forcing AJAX request to revalidate cache with server, without reloading completely

Upvotes: 1

Views: 2245

Answers (1)

LoVo
LoVo

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

Related Questions