Forum Moderators: phranque

Message Too Old, No Replies

Far Future Expires Header not working

         

StoutFiles

4:50 pm on Jun 12, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Here's the code I'm using in my .htaccess file.

<FilesMatch "\.(ico¦pdf¦flv¦jpg¦jpeg¦png¦gif¦js¦css¦swf)$">
Header set Expires "Thu, 15 Apr 2015 20:00:00 GMT"
</FilesMatch>

Yet YSlow says I'm not doing it right. Is there something I'm doing wrong?

jdMorgan

6:10 pm on Jun 12, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



See Apache mod_expires. Then use mod_headers to set the Cache-control header if necessary, so that it does not contain "no-cache", "must-revalidate", or any other cache-control directive except for the max-age directive inserted by mod_expires.

Here's an example of the relevant response headers from one of my servers for a gif image, set to expire after 10 days:

Cache-Control: max-age=864000
Expires: Sun, 22 Jun 2008 17:55:27 GMT
Last-Modified: Wed, 20 Dec 2006 23:52:40 GMT
Etag: "3647960-14b5-4589ccc8"
Content-Type: image/gif

This is done with the directives:

<FilesMatch "\.(gif¦jpe?g¦png¦css¦js¦ico¦pdf¦flv¦swf)$">
#
Header unset Cache-control
#
ExpiresActive On
ExpiresDefault A864000
#
</FilesMatch>

Note that "jpeg¦jpg" has been compressed to "jpe?g", and that the filetypes are re-ordered so that the most-frequently-requested filetypes appear earlier in the list. These are minor performance tweaks, but can help on a busy site.

Replace all broken pipe "¦" characters with solid pipe characters before use" Posting on this forum modifies the pipe characters.

Jim

StoutFiles

6:48 pm on Jun 12, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well here's what I ended up with using that code, edited for a longer time.

Date: Thu, 12 Jun 2008 18:41:41 GMT
Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.8g DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
Last-Modified: Fri, 16 May 2008 01:16:23 GMT
ETag: "23cc500-5d-44d4ec31ba7c0"
Accept-Ranges: bytes
Content-Length: 93
Expires: Mon, 29 Aug 2016 18:41:41 GMT
Content-Type: image/png

I believe that's what I want? YSlow still doesn't recognize it but if it's working then that's ok. Thanks for your help.