11

I'm tearing my hair out over Internet Explorer 9's caching.

I set a series of cookies from a perl script depending on a query string value. These cookies hold information about various things on the page like banners and colours.

The problem I'm having is that in IE9 it will always, ALWAYS, use the cache instead of using the new values. The sequence of events runs like this:

  1. Visit www.example.com/?color=blue
  2. Perl script sets cookies, I am redirected back to www.example.com
  3. Colours are blue, everything is as expected.
  4. Visit www.example.com/?color=red
  5. Cookies set, redirected, colours set to red, all is normal
  6. Re-visit www.example.com/?color=blue
  7. Perl Script runs, cookies are re-set (I have confirmed this) but! IE9 retreives all resources from the cache, so on redirect all my colours stay red.

So, every time I visit a new URL it gets the resources fresh, but each time I visit a previously visited URL it retrieves them from the cache.

The following meta tags are in the <head> of example.com, which I thought would prevent the cache from being used:

<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE"> 
<META HTTP-EQUIV="EXPIRES" CONTENT="0">

For what it's worth - I've also tried <META HTTP-EQUIV="EXPIRES" CONTENT="-1">

IE9 seems to ignore ALL these directives. The only time I've had success so far in that browser is by using developer tools and ensuring that it is manually set to "Always refresh from server"

Why is IE ignoring my headers, and how can I force it to check the server each time?

Florent
  • 12,310
  • 10
  • 49
  • 58
Andy F
  • 1,517
  • 2
  • 20
  • 35
  • have you looked at http://stackoverflow.com/questions/4360283/http-cache-control ? tried private? – Oleg Mikheev Nov 23 '11 at 09:20
  • OK I've just tried setting it to CONTENT="PRIVATE" and 'm experiencing the same problem. – Andy F Nov 23 '11 at 09:47
  • 2
    Try doing a client-side API call... in this case even "Always refresh from server" is not working. I now have IE9 almost as much as I hate IE6 – Vroomfundel Nov 29 '11 at 23:23

6 Answers6

7

Those are not headers. They are <meta> elements, which are an extremely poor substitute for HTTP headers. I suggest you read Mark Nottingham's caching tutorial, it goes into detail about this and about what caching directives are appropriate to use.

Also, ignore anybody telling you to set the caching to private. That enables caching in the browser - it says "this is okay to cache as long as you don't forward it on to another client".

Jim
  • 72,985
  • 14
  • 101
  • 108
3

Try sending the following as HTTP Headers (not meta tags):

Cache-Control: private, must-revalidate, max-age=0
Expires: Thu, 01 Jan 1970 00:00:00
johnstok
  • 96,212
  • 12
  • 54
  • 76
2

I don't know if this will be useful to anybody, but I had a similar problem on my movies website (crosstastemovies.com). Whenever I clicked on the button "get more movies" (which retrieves a new random batch of movies to rate) IE9 would return the exact same page and ignore the server's response... :P

I had to call a random variable in order to keep IE9 from doing this. So instead of calling "index.php?location=rate_movies" I changed it to "index.php?location=rate_movies&rand=RANDOMSTRING".

Everything is ok now.

Cheers

Pedro Araujo Jorge
  • 642
  • 2
  • 9
  • 19
0

Will just mention that I had a problem looking very like this. But I tried IE9 on a different computer and there was no issue. Then going to Internet Options -> General -> Delete and deleting everything restored correct behaviour. Deleting the cache was not sufficient.

peter2108
  • 5,580
  • 6
  • 24
  • 18
0

The only items that HTML5 specifies are content-type, default-style and refresh. See the spec.

Anything else that seems to work is only by the grace of the browser and you can't depend on it.

Zan Lynx
  • 53,022
  • 10
  • 79
  • 131
-2

johnstok is correct. Typing in that code will allow content to update from the server and not just refresh the page.

<meta http-equiv="Content-Type" content="text/html; charset=utf-8; Cache-Control: no-cache" />

put this line of code into your section if you need to have it in you asp code and it should work.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807