浏览器在不需要时检查是否已修改(结果= 304)

时间:2009-12-27 07:44:29

标签: performance http browser caching

我正在尝试阻止从客户端到服务器的If-modified请求,但我失败了。 我认为我遗漏了一些东西所以我附加了两个请求的HTTP通信。我希望不会发出第二个请求:

GET XXXXX/js/Is.js HTTP/1.1
Accept: */*
Referer: http://XXXXX/XXXXX/
Accept-Language: he
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Hewlett-Packard; .NET CLR 1.0.3705; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
Host: xxxxxxxx:8080
Connection: Keep-Alive
Pragma: no-cache
Cookie: JSESSIONID=XXXXXX



HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Pragma: No-cache
Cache-Control: public,max-age=860000
Expires: Sun, 3 Jan 2010 00:00:00 GMT
ETAG: W/"1634-1260925588406"
Last-Modified: Wed, 16 Dec 2009 01:06:28 GMT
Content-Encoding: gzip
Content-Type: text/javascript
Content-Length: 412
Date: Sun, 27 Dec 2009 07:25:52 GMT




GET /XXXXXXXX/Is.js HTTP/1.1
Accept: */*
Referer: http://XXXXXXXXX/XXXXXXX/servlet/Main
Accept-Language: he
UA-CPU: x86
Accept-Encoding: gzip, deflate
If-Modified-Since: Wed, 16 Dec 2009 01:06:28 GMT
If-None-Match: W/"1634-1260925588406"
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Hewlett-Packard; .NET CLR 1.0.3705; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
Host: xxxxxx:8080
Connection: Keep-Alive
Pragma: no-cache
Cookie: JSESSIONID=XXXXXX; 

HTTP/1.1 304 Not Modified
Server: Apache-Coyote/1.1
Pragma: No-cache
Cache-Control: public,max-age=860000
Expires: Sun, 3 Jan 2010 00:00:00 GMT
ETAG: W/"1634-1260925588406"
Date: Sun, 27 Dec 2009 07:34:33 GMT

3 个答案:

答案 0 :(得分:1)

第二个请求中的Pragma: no-cache表示它是由于页面刷新而发生的。在这种情况下,304是正确的响应。如果要强制重新读取,则应使用control-refresh。

答案 1 :(得分:0)

您在第一次回复中发送了Pragma: No-cache。来自缓存的prevents Firefox

答案 2 :(得分:0)

我认为我找到了问题......我知道我错过了什么 加载的第一个文档正在重定向:

 <meta HTTP-EQUIV="Refresh" CONTENT="1; URL=/XXXXX">

感谢您的帮助......