浏览器缓存 - 为什么IE9在没有访问网络时总是显示http 304? [英] Browser caching - Why does IE9 always show http 304 when actually it did not hit the network?

查看:487
本文介绍了浏览器缓存 - 为什么IE9在没有访问网络时总是显示http 304?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试正确设置缓存,并且将Expires标头设置为将来365天正常工作但在IE9中无法正确显示。有谁知道为什么?

I am trying to set up caching correctly and have set Expires headers to 365 days in the future which is working correctly but not showing correctly in IE9. Does anyone know why?

当您访问IE9中的任何网站(例如www.google.com)时,请在地址栏中单击Enter以重新访问它,并显示完整的缓存很多额外的304,Fiddler没有显示。

When you visit any website in IE9 (eg www.google.com) then click Enter in the address bar to revisit it with full caching it shows a lot of extra 304s which Fiddler does not show.

查看网络检查器选项卡(在F12上),IE9显示它已收到针对CSS的304 Not Modified响应和JS文件和3张图片(可能是大约在过去一个月内修改日期的图片 - 其他30张未显示的图片较旧)。

Looking in the network inspector tab (on F12), IE9 shows that it has received 304 Not Modified responses for CSS and JS files and 3 images (possibly images with modified dates within approx past month - the other 30 images not shown are older).

然而,根据Fiddler和看IIS登录我正在开发的网站上的服务器,它实际上没有提出这些请求。 IE9网络时间线显示这些灰色302s没有等待时间和<1ms响应时间 - 而如果我按下F5它们也是灰色302s但显示为几毫秒等待和下载时间(并且它们命中网络)。

However, according to Fiddler and looking at IIS logs on the server on the website I am developing, it has not actually made these requests. The IE9 network timeline shows these grey 302s as no wait time and "<1 ms" response time - whereas if I hit F5 they are also grey 302s but shown as several milliseconds waiting and downloading time (and they hit the network).

那么为什么IE9网络检查员认为它发出了这些条件请求?在它到达Fiddler之前,它是否实际发出了某个网络堆栈中满足的请求?

So why does IE9 network inspector think it issued a conditional request for these? Did it actually issue a request that was satisfied within the network stack somewhere, before it got to Fiddler?

Chrome将所有请求(包括所有图像)显示为灰色200(来自缓存),而不是页面本身,这是一个黑色200(根据Fiddler和IIS,这是正确的)日志)。

Chrome shows all requests, including all images, as grey 200 (from cache) apart from the page itself which is a black 200 (which is correct according to Fiddler and IIS logs).

Firebug为CSS和JS显示灰色200 OK,奇怪的是只有一个图像(也正确,假设灰色200表示来自缓存 - 但为什么只显示这些资源而不是所有其他资源图片?)

Firebug shows grey 200 OK for CSS and JS and oddly just one image (also correct assuming grey 200 means from cache - but why show only these resources and not all the other images?)

我一直在阅读Eric Lawrence关于IE9缓存和网络堆栈的博文,但他没有提到这种奇怪的行为。

I've been reading Eric Lawrence's blog posts about IE9 caching and network stack but he doesn't mention this odd behaviour.

推荐答案

为了清楚起见,如果你没有在Fiddler中看到它,它就没有进入网络。

Just to be clear, if you don't see it in Fiddler, it didn't hit the network.

IE网络选项卡有许多错误 - 其中之一是它很难区分本地满足的缓存命中(例如没有网络命中)和需要与服务器重新验证的一个(例如304)。

The IE Network tab has a number of bugs-- one of them is that it has a hard time distinguishing between a cache hit satisfied locally (e.g. no network hit) and one that required revalidation with the server (e.g. a 304).

这是因为缓存在WinINET中被关闭,远低于网络选项卡,它位于URLMon之上。

That's because the cache is serviced down in WinINET, well below the Network tab, which lives up above URLMon.

话虽如此,这里有另一个你可能想要查看的参考:有条件请求的IEInternals博客

Having said that, here's another reference you may want to check out: IEInternals Blog on Conditional Requests

这篇关于浏览器缓存 - 为什么IE9在没有访问网络时总是显示http 304?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆