Friday, April 27, 2012

Getting IE to really, really, load fresh content

I was really laughing when I read the description of this guy's problem on superuser:

When using Internet Explorer 8 to test my web application I often find it doesn't reload the page, so I don't see my changes. This has resulted in a lot of wasted time and frustration wondering why my fix "didn't work" - when in fact the browser never loaded the fixed version.
I've tried the Refresh button. I've tried F5, Control-F5, Control-R, Control-Shift-R, holding Control while clicking the Refresh button, everything I could think of - it doesn't actually load the new contents from the server. I've confirmed this with Fiddler.
How do I tell IE "I don't care what you think you have cached, I want to reload the page - no really, I mean it this time, honest-to-God, I want you to actually go to the server and download everything again"?

I laughed, because I get it. I've had to work with IE hanging on to stuff - like favicons, for example.

But what I learned from the page was from a comment:

Ev: The user-facing side of this is usually fixed by changing the URLs for all scripts and stylesheets every time you touch the code, typically by adding a ?version-number query string suffix.bobince Dec 10 '09 at 1:53

My sysadmin suggested that we could even add a server side option to change the querystring every 24 hours.

The side note to this was even stranger, and another recurring problem that I have. I found that page, because I was having some IE users not able to update a shopping cart after an upgrade, and I thought they might not have been getting the right file.

Turns out - the customer was using IE Compatibility mode. Not that they were aware of that, or that it was intentional....

1. Javascript/CSS versioning to force update
2. Check Cache and Compatibility Mode when there are issues.

No comments: