asp.net - IE 似乎没有缓存我的图像

标签 asp.net html css asp.net-mvc iis-7

我真的希望有人有一些想法。我已经将我的网络配置设置为缓存图像 30 天。

网络配置:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <staticContent>
      <clientCache cacheControlCustom="public" cacheControlMode="UseMaxAge" cacheControlMaxAge="30.00:00:00" />
    </staticContent>
  </system.webServer>
</configuration>

然而,当我请求带有 IE 的页面并检查网络流量时,这是我看到的:

Request Header:

Key Value
Request GET http://www.xx.com/Content/Icons/login.png HTTP/1.1
Accept  image/png, image/svg+xml, image/*;q=0.8, */*;q=0.5
Referer http://www.selftestware.com/
Accept-Language en-US
User-Agent  Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
Accept-Encoding gzip, deflate
Host    www.xx.com
If-Modified-Since   Wed, 24 Aug 2011 15:48:10 GMT
If-None-Match   W/"0195d397562cc1:0"
Proxy-Connection    Keep-Alive
Pragma  no-cache
Cookie  __utma=xx

Response:

Key Value
Response    HTTP/1.1 200 OK
Cache-Control   public,max-age=2592000
Content-Type    image/png
Last-Modified   Wed, 24 Aug 2011 15:48:10 GMT
Accept-Ranges   bytes
ETag    W/"0195d397562cc1:0"
Server  Microsoft-IIS/7.5
X-Powered-By    ASP.NET
Date    Wed, 24 Aug 2011 10:39:14 GMT
Content-Length  727

它不应该发送 304(未修改)。我就是不明白这里出了什么问题。

最佳答案

您的请求 header 已发送“Pragma: no-cache”,这意味着告诉服务器不要缓存此请求。这就是您的服务器响应 HTTP 200 而不是 HTTP 304 的原因。

这个“Pragma: no-cache”是由浏览器发送的。如果您按 Ctrl+F5 热键或将您的浏览器配置为不缓存任何内容,将导致此结果。您可以尝试创建一个包含指向此缓存页面的链接的空白页面,然后单击它上面的链接。您会看到此页面已被缓存。

关于asp.net - IE 似乎没有缓存我的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7174638/

相关文章:

javascript - 绝对div中的jQuery滚动条插件

asp.net - 如何使用EntityFramework代码优先迁移来播种数据

javascript - 如何找到选项卡关闭并清除本地存储

javascript - 选择选项时隐藏 Div

css - 使用 npm 的 Node Sass CSS 导入器

html - Angular 落没有出现在顶部

asp.net - Oracle中数百个实体(表)的CRUD操作

c# - 动态生成 XML 节点

asp.net - udl 连接字符串有效,但我的 ASP.Net 文件在连接时抛出异常

php - 从多维数组创建 Html 元素