Morning all
Have come across an issue (that I'm hoping is a lack of understanding on my part) in IE9.
Scenario:
An external javascript is attached to a screen and executed via onchange against various fields. If I change the javascript, clear the browser cache (via safety --> delete browsing history) and restart the browser it still uses the old cached version of the js.
I've investigated on the web and have found this type of deep-seated caching is, it seems, by design. For instance, see http://forums.asp.net/t/1728141.aspx/1
Anyone else experiencing this or have any thoughts? I really do not want to be advising all users to do that kind of js cache clearing when we make a change to the js.
Regards
Rob.
Javascript cache
-
- Profound User
- Posts: 42
- Joined: Mon Jun 27, 2011 9:11 am
- First Name: Rob
- Last Name: Horton
- Company Name: Design Group Plc
- Contact:
-
- Experienced User
- Posts: 2711
- Joined: Wed Aug 01, 2012 8:58 am
- First Name: Scott
- Last Name: Klement
- Company Name: Profound Logic
- City: Milwaukee
- State / Province: Wisconsin
Re: Javascript cache
I'm not sure that "Browsing History" contains the JavaScript cache, does it? (I don't use IE very often, so I may be wrong about that.) When I want to clear JavaScript cache, I go into the F12 Developer Tools, then click "Cache", and "Clear browser cache for this domain."
If you want your JavaScript to be reloaded each time the screen is displayed (Note: this can slow things down considerably -- that's why browsers cache the data) then you could do so by adding a random number, or similar, to the URL for the JavaScript. For example (this is off the top of my head and untested) you might set your external js to:
If you want your JavaScript to be reloaded each time the screen is displayed (Note: this can slow things down considerably -- that's why browsers cache the data) then you could do so by adding a random number, or similar, to the URL for the JavaScript. For example (this is off the top of my head and untested) you might set your external js to:
Code: Select all
js: "/yourdir/test.js?rnd=" + Math.random()
-
- Profound User
- Posts: 42
- Joined: Mon Jun 27, 2011 9:11 am
- First Name: Rob
- Last Name: Horton
- Company Name: Design Group Plc
- Contact:
Re: Javascript cache
Morning Scott
Thanks for the reply. As for browsing history, I appreciate just deleting the sites visited wouldn't have any impact but it does do things like cookies etc. so I was hoping js cache clear would be accessible from there, as oppposed to a developer menu.
After thinking about it (always a dangerous thing) I'm coming round to having a version number as part of the javascript file name, almost like a file level ID, although it does mean that if I end up with generic functions called all over the place then I'll have to change it in those places to use the new version when I make a change.
Do you see where I'm coming from? I guess that in reality I'm going to experience this more myself as I develop and make constant changes to the js. Once live it shouldn't change that often at all.
I certainly do want caching to be left on - it would just be nice if IE was able to detect a change in the js file (be it modified date etc.) and to automatically refresh as and when needed.
Regards
Rob.
Thanks for the reply. As for browsing history, I appreciate just deleting the sites visited wouldn't have any impact but it does do things like cookies etc. so I was hoping js cache clear would be accessible from there, as oppposed to a developer menu.
After thinking about it (always a dangerous thing) I'm coming round to having a version number as part of the javascript file name, almost like a file level ID, although it does mean that if I end up with generic functions called all over the place then I'll have to change it in those places to use the new version when I make a change.
Do you see where I'm coming from? I guess that in reality I'm going to experience this more myself as I develop and make constant changes to the js. Once live it shouldn't change that often at all.
I certainly do want caching to be left on - it would just be nice if IE was able to detect a change in the js file (be it modified date etc.) and to automatically refresh as and when needed.
Regards
Rob.
-
- Experienced User
- Posts: 2711
- Joined: Wed Aug 01, 2012 8:58 am
- First Name: Scott
- Last Name: Klement
- Company Name: Profound Logic
- City: Milwaukee
- State / Province: Wisconsin
Re: Javascript cache
A version number would probably work very nicely! good idea.
Who is online
Users browsing this forum: No registered users and 4 guests