Leveraging browser caching

Discussion in 'Apache' started by canalboatman, Jul 13, 2010.

  1. #1
    I'm having problems using .htaccess to leverage browser caching, which would be an improvement to the speed of my site, as Firebug tells me.

    Searching around I have found code which I have inserted into my .htaccess file.

    The .htaccess file already contains the following:

    <filesMatch ".js$">
    AddHandler application/x-httpd-php .js
    </filesMatch>

    Which works.

    When I add the following code to create the browser caching........

    # Turn on Expires and set default to 0
    ExpiresActive On
    ExpiresDefault A0

    # Set up caching on media files for 1 year (forever?)
    <FilesMatch "\.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav)$">
    ExpiresDefault A29030400
    Header append Cache-Control "public"
    </FilesMatch>

    # Set up caching on media files for 1 week
    <FilesMatch "\.(gif|jpg|jpeg|png|swf)$">
    ExpiresDefault A604800
    Header append Cache-Control "public"
    </FilesMatch>

    # Set up 1 Hour caching on commonly updated files
    <FilesMatch "\.(xml|txt|php|html|js|css)$">
    ExpiresDefault A3600
    Header append Cache-Control "proxy-revalidate"
    </FilesMatch>

    # Force no caching for dynamic files
    <FilesMatch "\.(cgi|pl|htm)$">
    ExpiresActive Off
    Header set Cache-Control "private, no-cache, no-store, proxy-revalidate, no-transform"
    Header set Pragma "no-cache"
    </FilesMatch>

    ......I get "Internal server error".

    Help!!
     
    canalboatman, Jul 13, 2010 IP