为什么我的 aspx 页面仅从我的开发计算机上的缓存请求
好的 - 所以我正在测试一个 Web 应用程序,并且在我的开发盒上遇到一些我无法解决的奇怪行为。在同事的机器上没有表现出相同的行为。
问题如下:我向index.aspx发出两个请求。第一个请求作为 HTTP 200 返回(正如我所期望的),但第二个请求是从浏览器缓存中检索的。我在每次测试开始时清除缓存,以确保测试的一致性。我还使用一个名为 HTTPWatch 的实用程序(很像 fiddler,但即使从浏览器缓存中检索请求也会显示请求),它向我显示 HTTP 信息,这就是我知道它来自缓存的方式。
该问题仅发生在我的一台机器上。
同事机器(工作正常)
- 请求发送到index.aspx
- 发送的标头:
- (请求行): GET /index.aspx HTTP/1.1
- 接受: text/html、application/xhtml+xml、/
- 接受编码: gzip、deflate
- 接受语言: en-GB
- 连接:保持活动状态
- Cookie:(不相关)
- 主机:开发
- 用户代理:Mozilla/5.0(兼容;MSIE 9.0;Windows NT 6.1;WOW64;Trident/5.0)
- 收到的标头:
- (状态行): HTTP/1.1 200 OK
- 缓存控制:私有
- 内容长度:10369
- 内容类型: text/html;字符集=utf-8
- 日期:2012 年 2 月 8 日星期三 09:09:38 GMT
- 服务器: Microsoft-IIS/7.5
- X-AspNet-版本:2.0.50727
- X-Powered-By: ASP.NET
- 发送的标头:
- 第二个请求发送到index.aspx
- 发送的标头:
- (请求行): GET /index.aspx HTTP/1.1
- 接受: text/html、application/xhtml+xml、/
- 接受编码: gzip、deflate
- 接受语言: en-GB
- 连接:保持活动状态
- Cookie:(不相关)
- 主机:开发
- 引荐来源: http://dev/index.aspx
- 用户代理:Mozilla/5.0(兼容;MSIE 9.0;Windows NT 6.1;WOW64;Trident/5.0)
- 收到的标头:
- (状态行): HTTP/1.1 200 OK
- 缓存控制:私有
- 内容长度:33588
- 内容类型: text/html;字符集=utf-8
- 日期:2012 年 2 月 8 日星期三 09:09:38 GMT
- 服务器: Microsoft-IIS/7.5
- X-AspNet-版本:2.0.50727
- X-Powered-By: ASP.NET
- 发送的标头:
我的机器(不起作用)
- 请求发送至索引.aspx
- 发送的标头:
- (请求行): GET /index.aspx HTTP/1.1
- 接受:application/x-ms-application、image/jpeg、application/xaml+xml、image/gif、image/pjpeg、application/x-ms-xbap、application/vnd。 ms-excel、application/vnd.ms-powerpoint、application/msword、/
- 接受编码: gzip、deflate
- 接受语言: en-GB
- 连接:保持活动状态
- Cookie:(不相关)
- 主机:开发
- 用户代理: Mozilla/4.0(兼容;MSIE 8.0;Windows NT 6.1;WOW64;Trident/4.0;SLCC2;.NET CLR 2.0.50727;.NET CLR 3.5.30729;. NET CLR 3.0.30729;媒体中心PC 6.0; .NET4.0C;.NET4.0E)
- 收到的标头:
- (状态行): HTTP/1.1 200 OK
- 缓存控制:私有
- 内容长度:10374
- 内容类型: text/html;字符集=utf-8
- 日期:2012 年 2 月 8 日星期三 09:45:304GMT
- X-Powered-By: ASP.NET
- 发送的标头:
- 第二个请求发送到 index.aspx
- 发送的标头:
- (无):没有为缓存项目发送标头
- 收到的标头:
- (无):未收到缓存项目的标头
- 发送的标头:
正如您可能已经注意到的,浏览器是不同的(ie8 到 ie9),但我仍然不明白为什么这会成为一个问题。我认为这一定是某种浏览器配置,因为第一个请求收到的标头实际上是相同的。
如果有人能解释为什么从缓存中检索第二个请求,我将非常感激。
Ok - so I am testing a web application and am getting some strange behaviour on my development box that I can't work out. The same behaviour is not exhibited on a colleagues machine.
The issue is as follows: I am making two requests to index.aspx. The first request comes back as a HTTP 200 (as I would expect), but the second request is retrieved from browser cache. I am clearing the cache at the start of each test to ensure the tests are consistent. I am also using a utility called HTTPWatch (a lot like fiddler, but shows requests even if they are retrieved from browser cache) which shows me HTTP information and this is how I know it is coming from the cache.
The issue only occurs on one of my machines.
Colleagues Machine (Works fine)
- Request is sent to index.aspx
- Headers Sent:
- (Request-Line): GET /index.aspx HTTP/1.1
- Accept: text/html, application/xhtml+xml, /
- Accept-Encoding: gzip, deflate
- Accept-Language: en-GB
- Connection: Keep-Alive
- Cookie: (Not relevant)
- Host: dev
- User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)
- Headers received:
- (Status-Line): HTTP/1.1 200 OK
- Cache-Control: private
- Content-Length: 10369
- Content-Type: text/html; charset=utf-8
- Date: Wed, 08 Feb 2012 09:09:38 GMT
- Server: Microsoft-IIS/7.5
- X-AspNet-Version: 2.0.50727
- X-Powered-By: ASP.NET
- Headers Sent:
- Second Request Sent to index.aspx
- Headers Sent:
- (Request-Line): GET /index.aspx HTTP/1.1
- Accept: text/html, application/xhtml+xml, /
- Accept-Encoding: gzip, deflate
- Accept-Language: en-GB
- Connection: Keep-Alive
- Cookie: (Not relevant)
- Host: dev
- Referer: http://dev/index.aspx
- User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)
- Headers received:
- (Status-Line): HTTP/1.1 200 OK
- Cache-Control: private
- Content-Length: 33588
- Content-Type: text/html; charset=utf-8
- Date: Wed, 08 Feb 2012 09:09:38 GMT
- Server: Microsoft-IIS/7.5
- X-AspNet-Version: 2.0.50727
- X-Powered-By: ASP.NET
- Headers Sent:
My Machine (Doesn't work)
- Request is sent to index.aspx
- Headers Sent:
- (Request-Line): GET /index.aspx HTTP/1.1
- Accept: application/x-ms-application, image/jpeg, application/xaml+xml, image/gif, image/pjpeg, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, /
- Accept-Encoding: gzip, deflate
- Accept-Language: en-GB
- Connection: Keep-Alive
- Cookie: (Not relevant)
- Host: dev
- User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)
- Headers received:
- (Status-Line): HTTP/1.1 200 OK
- Cache-Control: private
- Content-Length: 10374
- Content-Type: text/html; charset=utf-8
- Date: Wed, 08 Feb 2012 09:45:304GMT
- X-Powered-By: ASP.NET
- Headers Sent:
- Second Request Sent to index.aspx
- Headers Sent:
- (None): No Headers sent for cached items
- Headers received:
- (None): No headers received for cached items
- Headers Sent:
As you may have noticed, the browsers are different (ie8 to ie9), but I still can't see why this would be an issue. I think it must be some browser configuration as the headers received on the first request are virtually the same.
If anyone can explain why the second request is being retrieved from cache, I would be very grateful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好的 - 所以我想我已经解决了。
看来 IE 在某处有一些陈旧的缓存,即使我明确清除缓存,这些缓存也没有被清除。
我使用 ProcMon 来监视进程并查看 IE 从缓存中获取文件时正在访问哪些文件。我发现尽管清除了缓存,但以下位置仍有一个目录被访问:
C:\Users\%username%\AppData\Local\Microsoft\Windows\Temporary Internet Files\Content.IE5\%Random Characters%\
我删除了C:\Users\%username%\AppData\Local\Microsoft\Windows\Temporary Internet Files\Content.IE5 文件夹的内容,现在我似乎没有得到上述行为。
我在谷歌上搜索了其他人在清除 IE 缓存时遇到的困难,但找不到太多。
说实话,我对这个不太确定!
OK - so I think I've resolved it.
It seems that IE had some stale cache somewhere that was not being cleared even when I explicitly cleared the cache.
I used ProcMon to monitor the process and see what file was being accessed when IE was fetching the file from cache. I saw that despite clearing my cache there was a directory being accessed in the following location:
C:\Users\%username%\AppData\Local\Microsoft\Windows\Temporary Internet Files\Content.IE5\%Random Characters%\
I deleted the contents of the C:\Users\%username%\AppData\Local\Microsoft\Windows\Temporary Internet Files\Content.IE5 folder and now I do not seem to get the behaviour above.
I searched on google for other people having difficulty with clearing the Cache in IE, but could not find much.
Not too sure about this one to be honest!
您可以更改 IE 的设置
Internet 选项->常规->浏览历史记录->设置->Internet 临时文件
将检查存储页面的较新版本更改为“每次访问该页面时”
You can change the setting of IE in
Internet Options->General->Browsing history->Settings->Temporary Internet files
Change the Check for newer version of stored pages to "Every time I visit the page"