Fixing the “Leverage browser caching” and “Enable Compression” from Google Page Speed in Joomla
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 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 ##
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 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.
- Setting browser caching
- WP Super Cache for WordPress was not working on a shared host.
- Website speed does matter – Speed up your Joomla Site
- Using a 301 redirect to avoid search engines seeing duplicate content.
- A website checker says that you don’t have gzip enabled. What about Brotli?
- How to prevent hotlinking with Frontpage published sites.
- Add Faveicons to your WordPress site
- Using Cloudflare with Westhost WordPress sites