Thursday, 3 March 2011

mod_expires on Ubuntu Server

I love Firebug, it's really the only reason I use Firefox rather than Chrome as my main browser.

I particularly like Google's Page Speed add-on for Firebug - except that I always ended up scratching my head about the "Leverage browser caching" messages I heard. This hasn't been a major problem as I've usually been working on a shared server - so couldn't do anything about it. After setting up an Ubuntu Server in EC2 however I realised that I could do something about it. After having a quick search around I found this post on Absolutely Tech which led me to this post on Absolutely Tech which enabled me to install mod_expires.

Basically the process I used was to check to see if mod_expires was installed using phpinfo(), after realising that it wasn't I did sudo a2enmod expires followed by sudo /etc/init.d/apache2 restart. Now I can cache all the images on my site by adding this to .htaccess in my root directory:

# Turn on the Expires engine
ExpiresActive On
# Expires a week after client accesses the file
ExpiresByType image/jpeg M604800
ExpiresByType image/gif M604800
ExpiresByType image/png M604800
ExpiresByType image/x-icon M604800

Job's a good'un!

My next job is to check out Google's mod_pagespeed.

No comments:

Post a Comment