I have a simple ajax command calling a URL to my server:
$.ajax({ type: "GET", url: "/action" });
And the response from my logs show as /action?_=1423024004825
Is there anyway to remove this?
_=#### is a cache buster. When you have the cache setting set to false it will append that to the query string to make it so browsers think it is a new request and not use a cached version of the response.
To stop it from getting appended just change the setting to true (cached responses will now be used)
jQuery.ajaxSetup({cache:true});
You can also set this on a per request basis by adding the cache setting to the options
jQuery.ajax({
type: "GET",
url: "/action",
cache:true
});
http://api.jquery.com/jQuery.ajax
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.