adding ExpiresDefault to .htaccess file

Aly picture Aly · Mar 12, 2011 · Viewed 8.4k times · Source

I have updated my .htaccess file to include the following:

<FilesMatch "\.(css|js)$">
ExpiresDefault "access plus 1 month"
</FilesMatch>

I am trying to tell the client that all css and js wont change for 1 month so they can cache they files.

I have 2 questions,

  1. Is this going to achieve what I want
  2. Since adding that I am now getting a 500 error, the whole .htaccess file is below:

    
    <FilesMatch "*\.(css|js)$">
    ExpiresDefault "access plus 1 month"
    </FilesMatch>
    # BEGIN Compression (DEFLATE)
    <IfModule mod_deflate.c>
    # Enable compression
    AddOutputFilterByType DEFLATE text/css text/javascript application/x-javascript text/html ``text/plain text/xml image/x-icon
    <IfModule mod_setenvif.c>
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
    BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
    </IfModule>
    <IfModule mod_headers.c>
    # Make sure proxies deliver correct content
    Header append Vary User-Agent env=!dont-vary
    # Ensure proxies deliver compressed content correctly
    Header append Vary Accept-Encoding
    </IfModule>
    </IfModule>
    # END Compression (DEFLATE)

Answer

Butifarra picture Butifarra · Apr 11, 2011

Make sure ExpiresActive ON is set inside of your FilesMatch directive before ExpiresDefault.