1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

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