jquery in the browser Ajax calls, the cache provides a good support, post can not be cached,
The reason for using post is that the data cannot be cached or the JSON attack is avoided (JSON can be hacked when it returns data)
Ajax in the global object provides some ways to support caching and conditionalgets functionality
$.ajax ({ ifmodified:true, cache:true, });
The ifmodified option defines whether the conditional get function is supported when Ajax calls, and jquery automatically handles the header value returned by the server named Last-modified.
It first requests the server to re-verify the entry using the Conditionalgets feature, and if the server returns a status code 304,jquery will reuse the entry in the cache.
Cache option: If False,jquery is appended with a timestamp after the requested URL to differentiate the previous URL address, so that each request is new, the requested data is definitely new
However, if the server explicitly defines that the response response cannot be cached, jquery is useless, and the cache option is ignored in the AJAX server, with the following disabled caches:
// Disable Caching Response.Cache.SetCacheability (Httpcacheability.nocache);
Server and client use conditional to verify cache data
The client places the entry in the cache, re-verifies after expiration, and the server must implement the conditional gets function (using Etags or Last modified header
JS Code
$.ajax ({ ifmodified:true,// This is the key true, Success:function (DATA,STATUS,XHR) { } });
Server code:
if (request.headers["if-modified-since"null ) { Returnnew httpstatuscoderesult ((int) httpstatuscode.notmodified); }
Browser caching problems using jquery in MVC