服务器响应状态= 304一个浏览器的GET请求,另外的200 [英] server responds to one browser's GET request with Status=304 and another's with 200

查看:1148
本文介绍了服务器响应状态= 304一个浏览器的GET请求,另外的200的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图调试我的的.htaccess 文件,其中包括:

I'm trying to debug my .htaccess file, which contains:

<FilesMatch "\.(html|swf)$">
  <IfModule mod_headers.c>
      Header set Cache-Control "no-cache, public"
  </IfModule>
</FilesMatch>

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresDefault "access plus 1 month"
    ExpiresByType text/html                     "access plus 0 seconds"
    ExpiresByType application/x-shockwave-flash "access plus 1 month"
</IfModule>

在同一个网页多次访问我在Safari中看到:

On repeated visits to the same webpage I see in Safari:

名称= Wrapper.html,方法= GET,状态= 200(OK),类型= text / html的

Name=Wrapper.html, Method=GET, Status=200 (OK), Type=text/html

名称= App.html,方法= GET,状态= 200(OK),类型=应用程序/ x-冲击波闪光

Name=App.html, Method=GET, Status=200 (OK), Type=application/x-shockwave-flash

和浏览器:

名称= Wrapper.html,方法= GET,状态= 304(不修改),类型= text / html的

Name=Wrapper.html, Method=GET, Status=304 (not modified), Type=text/html

名称= App.html,方法= GET,状态= 304(不修改),类型=应用程序/ x-冲击波闪光

Name=App.html, Method=GET, Status=304 (not modified), Type=application/x-shockwave-flash

现在的问题是Safari浏览器从服务器上下载时,它应检索缓存,而Chrome浏览器缓存正确检索。

The problem is Safari downloads from server when it should retrieve from cache, whereas Chrome correctly retrieves from cache.

那么,如何才能获得状态= 304 从服务器到Safari(看到了Chrome浏览器)? (我猜这是根本原因,让我知道如果不)

So, how do I get Status=304 from the server to Safari (as seen for Chrome)? (I'm guessing this is the root cause, let me know if not)

更新

我只是检查缓存文件,似乎Safari浏览器是不是将下载文件到缓存摆在首位,因为它从在今后的访问得出。不知道为什么。

I just checked the cache file, and it seems Safari is not placing the downloaded files into the cache in the first place, for it to draw from upon future visits. Not sure why.

推荐答案

这没有什么关系服务器,也不是htaccess文件。 Safari浏览器发送请求需要一个如果修改 - 因为头,否则Apache将不与304,如果的Last-Modified 时间是一个是在请求之前。

This doesn't have anything to do with the server nor the htaccess file. The request that Safari sends needs an If-Modified-Since header or else apache won't respond with a 304 if the Last-Modified time is before the one that was in the request.

我不知道为什么Safari浏览器不发送头,还是它只是发生在某些时候还是必须做一些浏览器设置的地方。但是,<一个href="http://stackoverflow.com/questions/13789855/safari-not-sending-if-modified-since-and-if-none-match-headers">you're不是唯一的一个,这是发生在的。

I don't know why Safari doesn't send the header, or whether it's just happening some of the time or has to do with some browser setting somewhere. But you're not the only one that this is happening to.

这篇关于服务器响应状态= 304一个浏览器的GET请求,另外的200的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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