tags:

views:

38

answers:

2

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. When 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...

A: 

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.

Robb
okz.. so in case of online site this will not happen.. the cache will be updated with new versions if exists..
deepu
A: 

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.

VinayC
thanks for the information
deepu
@Deepu, if you want to release new version of js in production environment then version number will be the better choice for query parameter (.../file.js?v=1.5.0.11). You can have a static utility method defined somewhere that can append such info to a url. While including js/css files, you can use server tags (<%= %>) and embed call to that method to get urls with version info embedded.
VinayC