Jump to content

mod expires and headers


mummana

Recommended Posts

Hi, I want to cache the static content for 7 days, I have the following settings in httpd.conf file.  The response code is always is coming as "200", the files are not caching,

 

**********************************************************************

 

# enable expirations

ExpiresActive On

 

# expire GIF images after one day

ExpiresByType image/gif "access plus 7 days"

 

# expire JPE/JPG/JPEG images after one day

ExpiresByType image/jpeg "access plus 7 days"

 

# expire CSS Files after one day

ExpiresByType text/css "access plus 7 days"

 

# expire swf Files after one day

ExpiresByType application/x-shockwave-flash "access plus 7 days"

 

# expire JavaScript after one day

ExpiresByType application/javascript "access plus 7 days"

ExpiresByType text/javascript "access plus 7 days"

 

# expire png images after one day

ExpiresByType image/png "access plus 7 days"

 

#mod_headers Caching

<FilesMatch "\.(ico|gif|jpg|jpeg|png|flv|pdf)$">

  Header append Cache-Control "public"

</FilesMatch>

 

<FilesMatch "\.(js|css|swf)$">

  Header append Cache-Control "public"

</FilesMatch>

 

**********************************************************************

 

Could you please check the above configurations and please let me know is there any problem.

 

Thanks

Srini

 

Link to comment
Share on other sites

How do you know what code it's returning?  If you're using raw headers, then of course it's always returning a 200 code.  It's the client's responsibility to cache it.  The expires header is just a suggestion.

 

 

Those same settings work perfectly on my local Apache setup.

 

 

LoadModule expires_module modules/mod_expires.so
ExpiresActive On
ExpiresByType image/jpeg "access plus 7 days"

 

GET /img.jpg HTTP/1.1
Host: <my host>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Cookie: bblastvisit=1217099639; bblastactivity=0
Pragma: no-cache
Cache-Control: no-cache

HTTP/1.x 200 OK
Date: Thu, 06 Nov 2008 22:14:28 GMT
Server: Apache/2.2.10 (Win32) mod_ssl/2.2.10 OpenSSL/0.9.8h PHP/5.2.5 DAV/2 SVN/1.4.6
Last-Modified: Thu, 06 Nov 2008 22:07:35 GMT
Etag: "600000003bfc9-423-45b0c862f3310"
Accept-Ranges: bytes
Content-Length: 1059
Cache-Control: max-age=604800
Expires: Thu, 13 Nov 2008 22:14:28 GMT
Keep-Alive: timeout=2, max=100
Connection: Keep-Alive
Content-Type: image/jpeg

 

 

Then a second request:

 

 

GET /img.jpg HTTP/1.1
Host: <my host>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Cookie: bblastvisit=1217099639; bblastactivity=0
If-Modified-Since: Thu, 06 Nov 2008 22:07:35 GMT
If-None-Match: "600000003bfc9-423-45b0c862f3310"
Cache-Control: max-age=0

HTTP/1.x 304 Not Modified
Date: Thu, 06 Nov 2008 22:15:26 GMT
Server: Apache/2.2.10 (Win32) mod_ssl/2.2.10 OpenSSL/0.9.8h PHP/5.2.5 DAV/2 SVN/1.4.6
Connection: Keep-Alive
Keep-Alive: timeout=2, max=100
Etag: "600000003bfc9-423-45b0c862f3310"
Expires: Thu, 13 Nov 2008 22:15:26 GMT
Cache-Control: max-age=604800

Link to comment
Share on other sites

Hi corbin, thanks for the reply.

 

I am using Firefox/HttpFox tool to check the status codes, for any no. of requests the static content files are not cacheing, The status code always 200.

 

This is on internet and we are getting the site over proxy server.

 

Any help!!

 

Thanks

Srini

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.