pages, css, javascript, images not caching on site using ssl

I've been managing a pretty hefty CRM ( for a client which has always run pretty slow, but as the client has started using it more, the slow down became a huge issue.

What I found (by tracking the downloads with firebug) was that the pages, stylesheets, javascript, icons, photos etc. were not being cached to the local machine - which was causing a HUGE performance issue. Each time a page was requested roughly 70 files needed to be re-downloaded amounting to about 2MB total. This is because by default, if you are running a site behind a secure layer (SSL) files are not cached by the client machine.

The directive in the header of each file tells the clients browser not to cache the files - but turns out this is pretty easy to fix. We can instruct apache to change the headers of files that should be cached by adding a snippet of code to the .htaccess file.

The instructions to do this I found here: and the snippet is also included below:

# 480 weeks
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=290304000, public"
# 2 DAYS
<FilesMatch "\.(xml|txt)$">
Header set Cache-Control "max-age=172800, public, must-revalidate"
<FilesMatch "\.(html|htm)$">
Header set Cache-Control "max-age=7200, must-revalidate"