views:

965

answers:

2

I am attempting to use the far future expires method to cut down my site's load time.

However when I access static files in firefox, the server still responds with HTTP/1.x 304 NOT MODIFIED. The request shouldn't even be made if the files are cached right?

Here are the relevant httpd.conf lines I have for apache 2.2:

LoadModule expires_module modules/mod_expires.so
LoadModule headers_module modules/mod_headers.so

<FilesMatch "\.(ico|pdf|flv|jpe?g|png|gif|js|css|swf)$">
ExpiresActive On
ExpiresDefault "access plus 1 year" </FilesMatch>

YSlow says that none of the static files have a far-future expiration date. Does anyone know what I'm doing wrong?

A: 

Add this line to your conf:

FileETag none

(although make sure it's only for your static files, because etag could still be useful for your dynamic Django views)

Van Gale
Thanks, tried it but it doesn't seem to change the behavior at all.
+2  A: 

I'm not sure if the ExpiresActive On belongs in the FilesMatch directive. I've got much the same thing implemented, and I put it outside.

From the docs, it looks like it doesn't belong there:

http://publib.boulder.ibm.com/httpserv/manual60/mod/mod%5Fexpires.html#expiresactive

I've got the expires header set on the directories with static files:

ExpiresActive On
<Directory /path/to/static/files>
    ExpiresDefault "access plus 6 months"
    Header append Cache-Control public
</Directory>
Gabriel Ross
It worked! Thanks.
Great. Remember to upvote the answer and "accept" it. :-)
Gabriel Ross