有人可以帮我解决 HTTP 缓存问题吗?
我认为如果我设置了“Expires”和“Cache-Control:max-age”请求标头,那么浏览器在 max-age 过去之前不会发出 GET 请求?
我的服务器看到很多有条件的 GET 请求,它以 304 回复。但是,如果可能,我想消除这些有条件的 GET,并让浏览器仅在认为资源已过期时才请求资源。
以下是我从 Chrome 中的开发人员工具中获得的详细信息:
Request URL:http://localhost:8080/img/branding.gif
Request Method:GET
Status Code:304 Not Modified
请求标头:
Cache-Control:max-age=0
If-Modified-Since:Thu, 22 Jul 2010 10:54:34 GMT
Referer:http://localhost:8080/
User-Agent:Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.99 Safari/533.4
响应标头:
Cache-Control:max-age=2246400, s-maxage=0
Connection:Keep-Alive
Content-Location:/img/branding.gif
Content-Type:image/gif
Date:Fri, 23 Jul 2010 15:06:10 GMT
Expires:Fri, 07 Jan 2011 15:06:10 GMT
Keep-Alive:timeout=15, max=100
Last-Modified:Thu, 22 Jul 2010 10:54:34 GMT
Pragma:cache
Server:Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)
我在我的 Java 代码中的过滤器中设置了缓存标头。代码在 Oracle 的 OC4J 上运行。
另外,我想通过 HTTPS 运行它。使用相同的标头是否也适用于 HTTPS?
提前致谢。