views:

209

answers:

4

I am serving a .aspx that contains Images. I haven't figured out yet how to force ie7(6) to fetch the images all the time (e.g redirects).

So far, I've added the following tags on my .aspx page:

<META Http-Equiv="Cache-Control" Content="no-cache">
<META Http-Equiv="Pragma" Content="no-cache">
<META Http-Equiv="Expires" Content="0">

And still, if I click the URL Bar and hit enter or do a redirect to that same page IE won't re-fetch the images.

What am I missing?

Other Notes:

ISS 5
IE7 7.0.5730.13
Works on Firefox and everywhere else but IE

Redirect Code:

Response.Redirect("url...", true);
+1  A: 

IIS is probably overriding those settings. Go into IIS Manager and find the folder where your images are located. Right-click and select Properties. Click on the HTTP Headers tab. Check the option "Enable content expiration" and "Expire immediately".

Paul Mrozowski
If thats the case, why would this work in Firefox?
Newbie
According to this KB http://support.microsoft.com/kb/234067, IE 4/5 (assuming it hasn't changed in later versions), "Cache-Control META HTTP-EQUIV tags are ignored and have no effect in Internet Explorer versions 4 or 5. To use Cache-Control this header must be specified using HTTP headers as described in the Cache-Control section above."
Paul Mrozowski
+2  A: 

You might just put a unique tag on the end of your image URLs to make sure the cache isn't hit. For example

<img src="/path/to/image.jpg?<%=DateTime.Now.Ticks.ToString()%>" />

Granted, if you're using WebForms you'll want to do it a little different, but still along those lines.

Hugoware
I think I might end up doing this, thanks!
Newbie
A: 

I don't know exactly why, but we solve a similar problem adding these lines to the aspx.cs file, in the PageLoad Event:

//Turn off cache
Response.Cache.SetCacheability(HttpCacheability.ServerAndNoCache);
Response.Cache.SetNoStore();

It could be useful to solve your problem too

http://royriojas.blogspot.com/2009/04/dealing-with-back-button-and-secured.html

roy riojas
Thanks but IE still keeps caching stuff after your recommendation.. arrgh!
Newbie
+1  A: 

See http://www.enhanceie.com/redir/?id=httpperf for an explanation of how HTTP caching works, and how you can cache or not-cache your files.

EricLaw -MSFT-
Very useful, thanks!
Newbie