1

I am using IE 7.0. I want to clear the cache for every new request. So i need java script code for clear the cache. In IE i am using one setting to fix the caching issues. This is location: Tools-Internet Options-Browsing History Settings-Every time i visit the web page-Ok. It works fine for the current IE browser. Now I need to implement this concept using Java script. Please suggest me.

Response.Buffer = False
Response.CacheControl = "no-cache"

I tried, but not working.

2
  • Do you control the requests to the JavaScript, like are they AJAX calls? Commented Jan 14, 2013 at 12:07
  • How come you are still using IE7? Microsoft stated that they would auto-upgrade users to IE8/IE9, depending on your operating system (reference: computerworld.com/s/article/9222811/…). Commented Jan 14, 2013 at 12:46

1 Answer 1

1

You can't clear the cache using JavaScript. You can, however, trick the browser into thinking the page is different than what is stored in the cache by appending a number to the end of the URL.

So, for example, if you want to ensure that the browser is using your latest JS, append a number to the end of the source attribute (a different number will be needed each time you wish to "trick" the browser caching):

<script src="myScript.js?1" />

If you want to clear the cache for the entire page, you need to be asking a different question: How to control caching with [enter server-side language here]?

Note: Your new question, if needed, should be asked in a new question on SO.

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

11 Comments

You mean append a number that changes. Appending the same number all the time would be a fail ;)
@Lloyd, I thought it was obvious. I updated it for clarity. Thanks in advance for your upvote :P
But where i can found myScript.js file. Actually i did the IE setting then its works fine. But still issues.
Yeh it was to me, I knew what you meant but gotta be clear for others that's all.
@user1304807 How are you doing the requests? Are they static script inserts or something dynamic?
|

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.