May 17

5 comments

Fixing the “Leverage browser caching” and “Enable Compression” from Google Page Speed in Joomla

By Christopher Mendla

May 17, 2013


Last Updated on December 1, 2019 by Christopher G Mendla

Many Joomla sites have speed issues. Google Page Speed tools can help identify potential areas for improvement. “Leverage Browser Caching”  and “Enable Compression” are often cited as potential areas for improvement.

You will get these messages even if you have Joomla’s cache and Gzip compression on. The Joomla Cache is a server cache, not a browser cache.

For the Gzip compression, you can add the the following code to your .htaccess file.

WARNING – errors in your .htaccess can bring your site down. Be VERY careful when you edit your .htaccess and be sure you know what you are doing. You should also be familiar with FTP and how to backup and restore your .htaccess if necessary.

AddOutputFilterByType DEFLATE text/html text/xml text/css text/plain

AddOutputFilterByType DEFLATE img/svg+xml application/xhtml+xml application/xml

AddOutputFilterByType DEFLATE application/rdf+xml application/rss+xml application/atom+xml

AddOutputFilterByType DEFLATE text/javascript application/javascript application/x-javascript

AddOutputFilterByType DEFLATE application/x-font-ttf application/x-font-otf

AddOutputFilterByType DEFLATE font/truetype font/opentype

The code below is also added to your .htaccess file. This will set the expires header in the user’s browser. You should not just copy the code but you should understand it. For example, we have a site where PDF files are updated regularly. For that particular site, we would not want a user’s browser to cache the file for a year. In that case, we remarked the line out (We could have also removed it)

## EXPIRES CACHING ##

ExpiresActive On

ExpiresByType image/jpg “access plus 1 year”

ExpiresByType image/jpeg “access plus 1 year”

ExpiresByType image/gif “access plus 1 year”

ExpiresByType image/png “access plus 1 year”

ExpiresByType text/css “access plus 1 month”

ExpiresByType application/pdf “access plus 1 month”

ExpiresByType text/x-javascript “access plus 1 month”

ExpiresByType application/x-shockwave-flash “access plus 1 month”

ExpiresByType image/x-icon “access plus 1 year”

ExpiresDefault “access plus 2 days”

## EXPIRES CACHING ##

In sites where we have applied this code, we have seen the Google Page Speed index go from about 40 to 60 or better. As with any changes you should benchmark your page speeds before and after applying this code.

————————————————————————————————————————–

We offer Joomla consulting – See www.cgmsystems.com for details. 

Christopher Mendla

About the author

Leave a Reply

Your email address will not be published. Required fields are marked

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}