js file is loading from cached temporary internet files instead of redownloading from server
I have used a external js file for a upload operation in my page.. once the file get loaded in temporary folder, it gets loaded from there even if new changes are made the old version that exist in temp folder gets loaded... i have written
Response.Cache.SetCacheability(HttpCacheability.NoCache);
on my page But it still loads the js file in cache. 开发者_StackOverflowWhen i cleared the temporary files manually it works fine...But i cannot ask my client to clear temp folder,,, Is there any solution to load js file not from the cache, ie reload every time page is loaded...
Setting cache headers on page will control caching of page output - it won't affect other files such as js files. But I would rather prefer js file to be cached so why you want to do otherwise is not clear. If its for development purposes then you can always hit browser refresh button to get fresh java-script file.
If you want to do it in production environment then you can append some random query parameter after the js file url (.../file.js?q=4563888
). You can use Environment.TickCount etc for generating the random number.
I'm assuming this is just for your while your developing, if frequent changes are made in production this wont help your users.
Most browsers allow you to ctrl+F5 to reload all content from a page rather than just a standard refresh of the page which loads images,css, js etc from cache.
精彩评论