Powered by Blogger.
Monday, March 4, 2013

Leverage browser caching of your joomla website very easily

Joomla websites are little bit slower than other cms. So its always an challenge for the developers to optimize the Joomla website well so that it remain fast on the web. Now when i was checking my Joomla websites rating at GTmetrix.com , i saw there recommendation about Leverage browser caching . It was a new term to me. So i started searching. After a while i found a way to do it correctly. And now i want to share it with you all.

Its very easy. All you have to do is just add a few line of code into your websites .htaccess file. Now all Joomla website have a htaccess.txt file on its root. You should always rename it to .htaccess ( dot htaccess ) so that it can take its effect. You can rename this file using an ftp client or cpanel file manager.
Now below is the code that you need to put at the very top of your htaccess file.



# Enable expirations
ExpiresActive On

# Default directive
ExpiresDefault "access plus 1 month"

# My favicon
ExpiresByType image/x-icon "access plus 1 year”

# Images
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"

# CSS
ExpiresByType text/css "access 1 month”

# Javascript
ExpiresByType application/javascript "access plus 1 year"


Thats it. You place this piece of code into your .htaccess file and it will leverage browser caching of your joomla website. So enjoy..