Trying to implement "future expiration date" for static files in django

I am trying to use the future future expires method to shorten my site load times.

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

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

LoadModule expires_module modules/
LoadModule headers_module modules/

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


YSlow says none of the static files have a distant future expiration date. Does anyone know what I am doing wrong?


source to share

2 answers

I'm not sure if it belongs ExpiresActive On

in the FilesMatch directive. I have the same thing implemented and I pulled it out.

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

I have an expires header set in directories with static files:

ExpiresActive On
<Directory /path/to/static/files>
    ExpiresDefault "access plus 6 months"
    Header append Cache-Control public




Add this line to your conf:

FileETag none


(though make sure this is only for your static files, because etag can still be useful for your Django dynamic views)



All Articles