开发者

Problem with Expires/Cache-Control Headers

I'm using Apache 2.2.16.

I've got the following HTML file in my htdocs folder:

<html>
 <link media="screen" type="text/css" href="/css/test.css" rel="stylesheet" />
 <body>XXXX</body>
</html>

I'm trying to make the CSS file cache in my browser so that it does not make another request for it, apart from on the first ever page load.

However, every time I press refresh, I can see that the CSS file is loaded again from the server. I see 200 response codes for the file in my server logs.

I've got the following in my httpd.conf file:

<LocationMatch "\.(css)$">
 Header set Cache-Control "max-age=2592000"
 Header set Expires "Thu, 15 Apr 2020 20:00:00 GMT"
 Header un开发者_StackOverflow社区set Last-Modified
 Header set Content-Type text/css
 Header unset ETag
</LocationMatch>

Here are my response headers, as reported by Firebug:

Date    Mon, 29 Nov 2010 10:48:49 GMT
Server  Apache/2.2.16 (Win32)
Accept-Ranges   bytes
Content-Length  18107
Cache-Control   max-age=2592000
Expires Thu, 15 Apr 2020 20:00:00 GMT
Content-Type    text/css
Keep-Alive  timeout=5, max=97
Connection  Keep-Alive

I've read a few articles about setting the caching headers, but I just can't see to get it working.

Any advice greatly appreciated.


I've seen similar problems with configurations that manually set expires & cache-control. Just letting mod_expires do that "heavy lifting" might already solve these issues?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜