1

Am developing a website in asp. So as of now as it is development time I don't want to cache my js/css as it will be undergoing changes.

But after deployment it is better to have caching as it is a longer run process.

Is there a single setting to accomplish this, preferably in IIS server.So whenever I need to take a fresh copy I just enable the setting in IIS

This has been a bottleneck for us as I need to instruct my client to do a cache clearing. Any help will be appreciated

1 Answer 1

2

Change the URL of css and js every time.Browser detects a different url and will not load the cached stylesheet/JS. You can change URL by simply adding random query string at end of URL.

http://mysite/style.css?Version=1
http://mysite/file.js?Version=1
Sign up to request clarification or add additional context in comments.

3 Comments

But what if i want caching. I need to change code. Is there any setting in IIS
Just remove the random query string from URL before making live. IF URL not change then browser will load the cache content.
@Robert_Junior Whenever the content of a file changes the version (timestamp, hash, random number) has to be modified. Therefore it will be safe to cache mysite/style.css?Version=1 because will never change, if style.css will be modified the link will become mysite/style.css?Version=2, mysite/style.css?Version=3 and so on and browser will load the new content. You may want to look at bundling too.

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.