45

How can I disable cache in IE8 ? We are doing Javascript development and testing it in IE8, but we have to clear the cache every time we make changes to the Javascript files.

1
  • 1
    If you have issues with it, so might your users. Better to use one of the non-accepted answers to force a refresh from the server.
    – user420667
    Commented Oct 16, 2013 at 20:30

10 Answers 10

70

Go to Internet Options. On the General tab, under Browsing History click Settings. Select the "Every time I visit the webpage" radio button.

This doesn't "disable" the cache per se, but it should fix your underlying problem - the JS files should be reloaded every time.

3
  • That's not something I can guarantee, you'll just have to test it.
    – EMP
    Commented May 3, 2010 at 3:58
  • 6
    In my experience this does not work for nested pages or controls that contain javascript. Commented Mar 9, 2011 at 21:38
  • 6
    A more reliable way is to do it from dev tools menu. Cache -> Always Refresh From Server as suggested buy Mac Commented May 16, 2013 at 18:26
16

Ctrl+F5 Should cause a full page refresh including all that cached javascript.

Occasionally though, you'll still need a cache clear, because even Ctrl+F5 won't work, for reasons beyond comprehension IE can't even get "refresh" right 100% of the time.

0
11

If that fails, a random parameter on the query string will do it:

index.html?a=346456

10

Load you JavaScript this way.

<html>
...
<script type="text/javascript">
document.write('<script src="yourscript.js?'+Math.random()+'"></script>');
</script>
...
</html>

Edit: In case this is not obvious, remove this code as soon you will go into production!

2
  • 2
    Only do this if you're developing, since caching is there to speed up page load times for good browsers. But then doing this will make it harder to come back and find, so maybe use a variable instead. Commented Aug 12, 2012 at 7:58
  • It really looks like hack and can be easily forgotten to remove it before bringing into production. Commented Dec 3, 2013 at 4:51
5

In order to set the browser cache turned off. Follow the instructions below:

MS IE

  1. from a menu select "Tools" for IE5 or "View" for IE4
  2. select "Internet Options"
  3. in "Temporary Internet Files" section click on "Settings"
  4. select "Every visit to the page" for "Check for newer versions of stored pages" save the settings I hope this may help please check
1
  • 1
    For IE8 and IE9, go to Internet Options -> General tab. In the Browsing History section, click on the Settings button, and choose "Every time I visit the webpage" under the Temporary Internet Files section, then click OK.
    – furman87
    Commented Jan 6, 2012 at 21:06
4

hit "Fn F12" to open developer tools

click Cache

choose "Always refresh from server"

Every time you refresh it should be clearing the cache, but there are also quick access cache clearing from the cache menu or the shortcuts that are active when the dev tools are open.

*Note- you must leave the dev tools window open, it doesn't have to be up front, but it has to remain open for the cache to remain disabled.

3

Ctrl+Shift+Del will open the Clear Private Data dialog (or select it from the Safety menu). Uncheck everything but the first two items to clear only the cache.

You shouldn't have to clear the cache though. If you access your js files through a web server (such as IIS running locally), the normal cache control mechanisms should do the trick. If they don't, a Ctrl+F5 usually fixes the problem.

3
  • The problem is that in production we want the browser to use the cache as the javascripts are massive. Which cache control mechanism are you talking about?
    – Lydon Ch
    Commented May 3, 2010 at 3:04
  • I was talking about development and testing. HTTP's Last-Modified, If-Modified-Since, and ETag headers let the browser and server figure out whether a file has been modified, and if it has, update the browser's cached version.
    – josh3736
    Commented May 3, 2010 at 3:41
  • Awesome, that worked! My problem was CSS not rendering when changed. Ctrl + Shift + Del was not working, however Ctrl + F5 finally cleared the cache. Commented Jul 5, 2013 at 14:17
2

If your javascript files are served exclusivley from a sub-directory, you could enable immediate content expiration for that directory in IIS. I recently had this problem serving content from a sub-directory and this was the fastest, simplest solution that I found.

1
  • 1
    That sounds like the best solution and it works whatever the server (not just IIS). Commented Jun 29, 2012 at 5:41
1

Open the IE debugging tools (F12), Cache on the menu, and select always refresh from server. This does mean you need to keep the debugging tools open.

0

Maybe a easier way not to have user refresh the browser is just to rename the js files (and css). This is what worked for me... as the server didn't like a random number after the .js file

1
  • 1
    Another hack is to just append a random query string to the end of the file (i.e. "mysite.com/myscript.js?random=B6646B155E" where random is a different value each time -- the server should ignore it, but the browser will avoid using a cached version.) This is useful when A.) you want to force ALL clients to get the latest script (not just your dev machine) and B.) you don't have access to server settings (such as when a page expires). Commented Oct 12, 2012 at 18:09

Not the answer you're looking for? Browse other questions tagged or ask your own question.