简体   繁体   中英

jQuery Ajax Caching Expiration Time

Is there a way to effectively handle the cache duration when making Ajax GETs? Please, note that I do NOT want to disable caching. I need to make an Ajax GET to the server and it is wonderful if this can be cached in the browser. However, there are times when content 1 hour old makes no sense so I need to tell: cache: true but for only 1 min. I need this on a per-request URL basis. Having a duration setting per-browser or per-application is not really useful.

What am I missing?

Thanks,

You can follow this strategy:-

Change the Etag every (period of time) in your asp.net MVC backend. Enable the 'cache:true' do look for Etag or last modified in Request Header (if any of change)

For Request headers, someone has written a nice answer, https://stackoverflow.com/a/12501696/713789

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM