简体   繁体   中英

How to clear cache with .Net

I tell them my problem. I have a fairly large site, where there are frequent changes. The same is made. Net F 3.5.

My big problem is that every time I make a rise in production I have to send a mail to all the people who use that site to clean your browser history. As it begins to have the same malfunction as it mixes the previous web with the latest version uploaded.

Is there any way to force a refresh of the page to a raise? but without disabling the cache? Since layers increases are 1 per month and cache for the size of the web is very useful.

You should add a hash to the assets url.

for example, if you need to include /scripts/yourscript.js , calculate the hash of the file and append it to the url:

<script src="/scripts/yourscript.js?hash=XYZ"></script>

This way, the URL will be unique to the version of the file, and the browser will differentiate each version. This will ensure the correct file is loaded.

You can calculate the hash of the file, use a timestamp, or anything that can differentiate the versions.

You can also play with http headers to set the caching policy. But the former advise is better (I think), because you can still combine caching benefits and versioning.

I think that the ScriptManager control can automatically do this hash for you (but I'm not sure)

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