How to force Images to be loaded all the time, ASP

2019-04-13 01:03发布

问题:

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:

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.



回答2:

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".



回答3:

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.



回答4:

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