Indrajeet
Indrajeet

Reputation: 47

caching using Javascript

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.

Upvotes: 1

Views: 133

Answers (1)

James Hill
James Hill

Reputation: 61802

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.

Upvotes: 1

Related Questions