4

I'm writing an asp.net project. When trying to fix a bug, I updated one of my javascript files and then deployed the new version on my server's IIS 6.0. I can see that the new javascript file has been updated on the physical folder of the website. However, when verifying the bug from my local machine I found that it's not fixed. After some investigation, I realized that it's because the javascript file received by my browser is not the latest version. I deleted IE's caches and the problem still exists. Then I tried to download the javascript directly from my website by using the url like: http://myserver.mydomain.com/mywebsite/scripts/myscript.js and found out the downloaded javascript file is of the old version. Then I realized this is probably caused by a cache on the server side. I tried to set the server's IIS: on my site's "Output Caching" option, I unchecked "Enable cache" and "Enable kernel cache"

:enter image description here

Also I added rules for .js and .css file: enter image description here

After taking all these actions, I updated my javascript file on the server, restarted IIS and tried to download it from my local machine again.However, the javascript I downloaded is still not the latest version.

So my question is, what shall I do to make sure the the browser can immediately get the latest version of the javascript file on my server's disk? Thanks!

1 Answer 1

2

I use the old trick of js and css versioning, for example if I create a new js file I call:

new_1.0.0.js

Then, if for some reason I change, I will change the name manually to:

new_1.0.1.js 

Also change all the parts where I Referencing. With this, your browser should always bring you the latest standalone version of the settings you have in the IIS. At least in my different jobs where I used II6 or II7 have applied and it has worked.

Sign up to request clarification or add additional context in comments.

3 Comments

Simple, but so obvious. Thanks for the idea !
It's crazy to me that there is no better solution for this. Been googling and trying various things to no avail. I've got about 30+ changed js files. Do i really need to go in and manually rename all of them and change all the references? That seems insane.
In C#, exists other trick using autogenerated JS renamed post compilation configuration. It using web.config section.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.