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

2019-04-13 00:33发布

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);

4条回答
ゆ 、 Hurt°
2楼-- · 2019-04-13 01:03

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

查看更多
Animai°情兽
3楼-- · 2019-04-13 01:18

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.

查看更多
Root(大扎)
4楼-- · 2019-04-13 01:20

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

查看更多
可以哭但决不认输i
5楼-- · 2019-04-13 01:25

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.

查看更多
登录 后发表回答