Now that Google is using website speed as a “signal” in it’s ranking algorithms (see related article) it is more important than ever to make your website as fast as you can without sacrificing your quality of content. There is one simply and easy change you can make to Apache (even if your website is hosted) to make your Joomla website substantially (80%+) faster for returning visitors.
When someone visits your website for the first time, it stands to reason that the page html, images, style sheets (css), flash swf’s, etc will all have to be downloaded from your website to render your webpage in the visitor’s browser. However, when someone returns to your website, it shouldn’t be necessary to re-download those same images, stylesheets, flash swf files, etc.
Joomla appears to do a poor job (compared with WordPress) of setting the browser cache expiration so that RE-downloading those same images, stylesheets, flash swf files, etc does NOT take place. The Apache mod_expires change I detail below will fix this, and this resulted in a more than 100% increase is speed for returning visitors on this website.
First measure your website performance BEFORE the change
Go to this awesome website to measure your current website performance.
- Go to http://www.webpagetest.org/.
- Click the New Test tab at the top of the page, and enter in your website URL and something in comments “Before change” perhaps.
- Next pick the location closest to you (for me it’s Dulles, VA USA.
- I recommend you choose IE8 (if it’s available for your location) as IE8 is the most popular browser in the world (currently at least).
- Check First View and Repeat View and set the number of runs to 4 so you get a reasonable average.
- Click Submit and wait for the test to finish (approximately 4 mins).
- Once the test is finished, you will see the results. Just above the “Key Optimizations” you will see Run 1 is the closest to the average load time, it may not be run 1, but which ever run it is, click it.
- For THIS article, we’re interested in the Repeat View. Make a note of the time underneath (for example 1.826s) which is in seconds.
- Click on the image to the right of Repeat View to see the files that are downloaded with every repeated view. You may want to take a screen shot of it to compare with after the change. See the “before the apache mod_expires change” performance of this website below.
Make the Apache Mod_Expires change
- Locate your .htaccess file. It should be in the root of your website directory. For the vast majority of website hosting companies who use cPanel, this will be under the public_html directory.
- Edit the .htaccess file. If using cPanel right-hand click on the file and select Code Edit.
- Add the following text to the bottom of the file.
########## Begin Enable Caching ##########
# enable expirations
# expire images after a month in the website visitor cache
ExpiresByType image/gif “access plus 1 month”
ExpiresByType image/png “access plus 1 month”
ExpiresByType image/jpeg “access plus 1 month”
ExpiresByType image/x-icon “access plus 1 month”
ExpiresByType text/css “access plus 1 week”
# expire flash and XML 1 month and 1 week respectively in the website visitor cache
ExpiresByType application/x-shockwave-flash “access plus 1 month”
ExpiresByType text/xml “access plus 1 week”
########## End Enable Caching ##########
- Save the file and then go to your website to make sure it’s still working correctly (it definitely should be, this isn’t a controversial change).
Now measure your website performance AFTER the change
Repeat the website performance test you performed at the start of this article and compare the difference. You should see a dramatic improvement! If you do, please post your results in the comments below!
You can see the performance of this website after the Apache Mod_expires change below.