- loading...
Debugging Javascript in IE7 – how to clear your Javascript cache
JavaScript first appeared in December 1995 within the Netscape browser.
131 months later and Microsoft latest attempt to provide JavaScript support in its browser is still faulty – deleting all browser files does not delete JavaScript files from your cache.
You try to develop JavaScript for IE7 and with each change you make the browser ignores it. “Delete files…” and refresh page. Nothing. “Delete all…” and refresh page. Nothing. “Delete all…” and restart browser and “Delete all…” and refresh page. Nothing.
A real “fist through the monitor” moment if there ever was one.
If you find this page via Google and you suffer the above pain, then consider this article your Support Group. “My name is Nic, I need JavaScript to work on IE7, and I have a problem.”
So did Daniel. He also had a solution. Good man, Daniel.
So, run the following Ruby script (if you use a different language, can you copy the equivalent into the comments, please, for fellow Support Group members?) to find and delete all JavaScript files in your cache.
files = ENV['USERPROFILE'] + '\\Local Settings\\Temporary Internet Files\\**\\*.js'
Dir[files.gsub(/\\\\/,'/')].each {|file| File.delete file; puts "Deleted: #{file}"}; nil
Create a script for it or just rerun that last line each time you want to clear all JavaScript in the cache.
The Support Group session is over. Coffee and cake is at the front of the room.
Related posts:
- Using CoffeeScript in Rails and even on Heroku I’m pretty excited about CoffeeScript as a clean-syntax replacement for...
- One-stop JavaScript Unit Testing for Rails 2.0 Previously, I mentioned a multi-step/multi-project solution to doing JavaScript Unit...
- newjs = newgem for JavaScript projects; free TDD suite Want to start a new JavaScript project for a library...
- Autotesting Javascript in Rails I used to love Javascript so much that it would...
del /s “%USERPROFILE%\Local Settings\Temporary Internet Files\*.js”
Umm, but with straight quotes.
Does the CTRL+SHIFT+click refresh trick work? I’ve tended to find this is a guaranteed “definitely reload everything” trick in most browsers after one or two goes, even IE (although I don’t have IE7 to test it on).
If you inline all your JS when you’re in the development environment, you can bypass the “clear cache” step completely.
You can still edit the actual .js files, but have the template inject the actual data into script tags instead of using the src attribute.
@zellyn – ahh, I forgot my DOS basics; thx
@peter – I’ll give that a try – unfortunately my inconsistent IE7 is now happily refreshing the JS without prompting.
@evan – ahh good point for testing the original code. I think I still need to src=”…” for dynamic data + code, but inlining would have worked for my original issues, I think.
Why the hell did they get rid of “Clear Cache” button???
ok found it… http://blogs.msdn.com/ie/archive/2006/01/12/512232.aspx
…and when you are really in a heap of trouble with the cache, how about renaming the javascript file… a bit of a pain, but should guarantee that the latest and greatest is downloaded to the browser. If this works the same as it does for images, than we should be in good shape!
(just a thought, not proven)
I need some help, the tags created with JavaScript that works in all the older versions of IE does not work with IE7. I’ve tried everything it just doesn’t seem to work.
Maybe you have a solution for my problem.
I have had nothing but problems with ie7, glad I found this post saved me even more trouble.
This example is for Microsoft Powershell, does the same thing and purges the js files from your cache.
# IE7 does not delete Javascript files when you “Delete files” from within IE.
# This is a workaround for that problem.
function purge-js
{
get-childitem “$env:userprofile\Local Settings\Temporary Internet Files” -include *.js -recurse -force | remove-item
}
Does anyone know a good javascript debugger for ie7 ?
Why the hell did they get rid of “Clear Cache” button
Here is the best solution….
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1841165&SiteID=1
Update the version number for each update.. This forces a reload
Apply changes…
Apply changes…
12 hrs wasted testing/building IE7 specific problem before i realised .js files weren’t refreshing – then i found this page and the magical “shift+ctrl+click refresh” saved me from insanity… 15 mins later problem solved!!!
…Not only did IE7 give me my original headache – but the muppets who built this crap made it near impossible for any normal person to develop a solution… maybe i should invoice microsoft for my wasted time – you owe me my weekend!
[...] 當 IE 用 <script>外嵌一個 javascript 的時候,只刪除 IE 的 Cache 是無法刪除被 IE Cache 住的 Javascript 的。有幾種方法可以解決: [...]