火狐浏览器IE:从缓存检索数据时损坏数据

发布于 2024-10-20 01:55:57 字数 2827 浏览 2 评论 0原文

我对服务器有一个请求,如下所示:

http://localhost/Combine.aspx/flag/file1.js,file2.js,file3.js

我也尝试过这个:

http://localhost/Combine.aspx/flag/value/file1.js/file2.js/file3.js

它只是组合了给定的三个文件:这工作正常。

当 Firefox 发出第一个请求时,页面会正确显示。当页面再次刷新时,内容如下所示:

��������`I�%&/m�{J�J��t��`$�����iG#)�*��eVe]f@�흼��{���{��;�N'

在这种情况下,据我所知,没有向服务器发出请求,仅从 Firefox 缓存中检索文件。

如果我使用 Control-F5 强制刷新页面,页面看起来又正常了。

这是使用Control-F5(有效)的请求和响应(在firebug中):

响应

Cache-Control   public
Content-Type    application/javascript; charset=utf-8
Content-Encoding    gzip
Expires Sun, 26 Feb 2012 02:57:26 GMT
Last-Modified   Fri, 07 Jan 2011 21:08:54 GMT
Etag    CLYvZwbFmainWEMi8h-6x-zNEIQ1
Vary    Accept-Encoding
Server  Microsoft-IIS/7.5
Set-Cookie  auth=longstring; path=/
X-AspNet-Version    2.0.50727
X-Powered-By    ASP.NET
Date    Thu, 03 Mar 2011 02:57:26 GMT
Content-Length  918

请求

Host    localhost
User-Agent  Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.14) Gecko/20110218 Firefox/3.6.14
Accept  text/html,application/xhtml+xml,application/xml;q=0.9,*/;q=0.8
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip,deflate
Accept-Charset  ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive  115
Connection  keep-alive
Cookie  auth=longstring
Pragma  no-cache
Cache-Control   no-cache

这里与相同F5(不起作用):

响应

Cache-Control   public
Content-Type    application/javascript; charset=utf-8
Content-Encoding    gzip
Expires Sun, 26 Feb 2012 02:57:26 GMT
Last-Modified   Fri, 07 Jan 2011 21:08:54 GMT
Etag    CLYvZwbFmainWEMi8h-6x-zNEIQ1
Vary    Accept-Encoding
Server  Microsoft-IIS/7.5
X-AspNet-Version    2.0.50727
X-Powered-By    ASP.NET
Date    Thu, 03 Mar 2011 03:01:31 GMT
Content-Length  1533

请求

Host    localhost
User-Agent  Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.14) Gecko/20110218 Firefox/3.6.14
Accept  text/html,application/xhtml+xml,application/xml;q=0.9,*/;q=0.8
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip,deflate
Accept-Charset  ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive  115
Connection  keep-alive
Cookie  auth=longstring

我能告诉的唯一不同的是内容长度(这可能会导致损坏),但由于它永远不会到达服务器,所以我无法控制它。

可能是什么原因造成的?

编辑:

这种情况也会发生在 IE8 上,但它不是查看损坏的文件,而是下载损坏的文件。从未向服务器发出任何请求(在 Visual Studio 中设置断点)。

至于chrome,直接查看url时,每次都会向服务器发出请求,每次都有效。但我相信,如果它包含在标签中,它的行为会与 Firefox 类似。

哦,还有:

如果我关闭 Expires 标头(这是 URL 中的标志之一),一切都会正常

编辑 2:

我可以通过不发送 Expires 和 ETag 标头,而只发送其中之一来解决此问题。不过,我不知道为什么 ETag 标头会导致这种损坏。

I have a request to the server which looks like this:

http://localhost/Combine.aspx/flag/file1.js,file2.js,file3.js

I have also tried this:

http://localhost/Combine.aspx/flag/value/file1.js/file2.js/file3.js

It simply combines the three files which it was given: this works fine.

Upon the first request from Firefox, the page displays correctly. When the page is refreshed again, the content looks like this:

��������`I�%&/m�{J�J��t��`$�����iG#)�*��eVe]f@�흼��{���{��;�N'

In that case, no request is made to the server, the file is only retrieved from the firefox cache, as far as I can tell.

If I force-refresh the page with Control-F5, the page looks normal again.

Here is the request and response (in firebug) with Control-F5 (works):

Response

Cache-Control   public
Content-Type    application/javascript; charset=utf-8
Content-Encoding    gzip
Expires Sun, 26 Feb 2012 02:57:26 GMT
Last-Modified   Fri, 07 Jan 2011 21:08:54 GMT
Etag    CLYvZwbFmainWEMi8h-6x-zNEIQ1
Vary    Accept-Encoding
Server  Microsoft-IIS/7.5
Set-Cookie  auth=longstring; path=/
X-AspNet-Version    2.0.50727
X-Powered-By    ASP.NET
Date    Thu, 03 Mar 2011 02:57:26 GMT
Content-Length  918

Request

Host    localhost
User-Agent  Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.14) Gecko/20110218 Firefox/3.6.14
Accept  text/html,application/xhtml+xml,application/xml;q=0.9,*/;q=0.8
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip,deflate
Accept-Charset  ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive  115
Connection  keep-alive
Cookie  auth=longstring
Pragma  no-cache
Cache-Control   no-cache

Here is the same with just F5 (doesn't work):

Response:

Cache-Control   public
Content-Type    application/javascript; charset=utf-8
Content-Encoding    gzip
Expires Sun, 26 Feb 2012 02:57:26 GMT
Last-Modified   Fri, 07 Jan 2011 21:08:54 GMT
Etag    CLYvZwbFmainWEMi8h-6x-zNEIQ1
Vary    Accept-Encoding
Server  Microsoft-IIS/7.5
X-AspNet-Version    2.0.50727
X-Powered-By    ASP.NET
Date    Thu, 03 Mar 2011 03:01:31 GMT
Content-Length  1533

Request:

Host    localhost
User-Agent  Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.14) Gecko/20110218 Firefox/3.6.14
Accept  text/html,application/xhtml+xml,application/xml;q=0.9,*/;q=0.8
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip,deflate
Accept-Charset  ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive  115
Connection  keep-alive
Cookie  auth=longstring

The only thing that I can tell is different is the Content-Length (which is likely causing the corruption), but since it never hits the server, I have no control over it.

What could be causing this?

Edit:

This happens on IE8 as well, but instead of viewing a corrupt file, it downloads the corrupt file. No request is ever made to the server (set a breakpoint in visual studio).

As for chrome, when viewing the url directly, a request to the server is made every time, and it works every time. I believe, though, that if it were included in a tag, it would behave similar to Firefox.

Oh, and also:

If I turn off the Expires header (which is one of the flags in the URL), everything works fine.

Edit 2:

I was able to work around this by not sending both an Expires and ETag header, only one or the other. I have no clue why an ETag header would cause such corruption, though.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

生活了然无味 2024-10-27 01:55:57

这是因为你的IIS配置。将 IIS 调整为 ASP 4.0 Classic,而不是默认应用程序池

It is because of your IIS configuration. Adjust IIS as ASP 4.0 Classic, not Default Application Pool

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文