简体   繁体   中英

ASP.NET App how do to clear Javascript cache

So I changed some jquery on a page in my application and it works fine etc.

But I just noticed that when I push the code to a different server and run the page on that server I need to hit ctrl + f5 to see the changes reflected. Is there a way when doing a code push to clear the cache on that page / javascript so it loads the latest version not the cached version.

on your referenced javascript file you can add a querystring, like:

<script src="/scripts/myfile.js?v=1" type="text/javascript"></script>

whenever you change the text in the file update the query string.

You need to take a look at your js files content expiry.

One way to solve this problem is to append a dummy query string parameter to all your *.js urls and set it to the build number of your app or file modified time.

/Scripts/file.js?v=1.0.12345.0

This will ensure that each build will use new urls and you can set their content expiry to never.

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