为什么我的文件没有从缓存中提供?
我认为我为我的域正确配置了缓存,但 Fiddler 和 Firefox webdeveloper 仍然向我显示所有图像、css 和 js 都会在每个请求上加载。
这是我的一张图像的响应标头:
Server nginx/0.8.36
Date Sat, 30 Apr 2011 05:02:58 GMT
Content-Type image/jpeg
Connction keep-alive
Last-Modified Fri, 08 Apr 2011 22:11:34 GMT
Etag "16456ec39f6cb1:0"
X-Powered-By ASP.NET
MicrosoftOfficeWebServer 5.0_Pub
MS-Author-Via MS-FP/4.0
Content-Length 2885
Expires Tue, 24 Apr 2012 05:02:58 GMT
Cache-Control max-age=31104000
X-Cache HIT
Accept-Ranges bytes
因此,我有 Expires 标头项,并且 Cache-Control 有一个 max-age 值(应该是一年)。 如果您想知道:这些文件最初是由 ASP.NET 提供的,但中间有一个 CDN,其中添加了一些标头项。
我的错误在哪里???
该请求就像“http://images.mydomain.com/filename.jpg”。没有附加唯一的查询字符串参数。
I think that I configured caching correctly for my domain but still both Fiddler and Firefox webdeveloper show me that all images, css and js are loaded on every request.
This is the response header for one of my images:
Server nginx/0.8.36
Date Sat, 30 Apr 2011 05:02:58 GMT
Content-Type image/jpeg
Connction keep-alive
Last-Modified Fri, 08 Apr 2011 22:11:34 GMT
Etag "16456ec39f6cb1:0"
X-Powered-By ASP.NET
MicrosoftOfficeWebServer 5.0_Pub
MS-Author-Via MS-FP/4.0
Content-Length 2885
Expires Tue, 24 Apr 2012 05:02:58 GMT
Cache-Control max-age=31104000
X-Cache HIT
Accept-Ranges bytes
So, I have the Expires header item and Cache-Control has a max-age value (should be one year).
If you're wondering: the files are originally served from ASP.NET but there is a CDN in between which is adding some header items.
Where is my mistake???
The request ist just like "http://images.mydomain.com/filename.jpg". There are no unique querystring parameters attached.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试添加
您可以在此处找到有关Cache-Control的更多信息.
您可以在此处<找到更多信息< /a>.
Try to add
You can find more about Cache-Control here.
You can find some more information here.
好吧,看来我不太会使用Fiddler。
我下载了 Chrome 来测试我的网站,Chrome 的开发人员工具告诉我我的文件来自缓存。
这就是我对上述标题的期望。
对我来说,悬而未决的问题仍然是,如果请求来自缓存,为什么 Fiddler 会显示这些请求。也许我会把它作为一个单独的问题发布:)
OK, it just seems that I am not able to use Fiddler very well.
I downloaded Chrome to test my web site and the developer tools of Chrome tell me that my files ARE coming from the cache.
That's what I would have expected with the above headers.
The open question for me remains why Fiddler is showing the requests if they are coming from the cache. Perhaps I'll post that as a separate question :)
看起来过期日期设置为过去。
Looks like Expires date set to the past.