Mobile app version of vmapp.org
Login or Join
Kevin317

: 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"

@Kevin317

Posted in: #Apache #Cache #CacheControl #HttpHeaders #WebDevelopment

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 unset 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.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Kevin317

1 Comments

Sorted by latest first Latest Oldest Best

 

@Kaufman445

I use the following:

ExpiresActive on
ExpiresDefault "access plus 24 hours"
ExpiresByType image/jpg "access plus 1 months"
ExpiresByType image/gif "access plus 1 months"
ExpiresByType image/jpeg "access plus 1 months"
ExpiresByType image/png "access plus 1 months"
ExpiresByType text/css "access plus 1 months"
ExpiresByType text/javascript "access plus 1 months"
ExpiresByType application/javascript "access plus 1 months"
ExpiresByType application/x-shockwave-flash "access plus 24 hours"


It's quite easier to maintain.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme