Speed Up your website with htaccess caching

If we are talking about SEO, then google has been announced that the speed of your web page also matter to improving your page rank and website performance. In this post we are talking about that how to improve the website loading performance so that the speed of loading the webpage also increase, and if you want to check the increased speed of your webpage the there is a page speed add-on available for Firefox, which is automatically integrated in firebug.

All this can happen with a single “.htaccess” file, which means htpertext access(htaccess). htaccess is just a simple but most powerful ASCII file. You can create this file with any editor.

Speed Up with Cache-Control headers

Cache Control gives you the power to boost your website performance. Below codes helps you store your website in cache. But before applying these codes make sure that you have enabled “mod_expires.so” and “mod_header.so” enabled in your httpd.conf apache configuration file.

# Caching for 1 YEAR
<filesMatch "\.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav)$">
Header set Cache-Control "max-age=29030400, public"
</filesMatch>

# Caching for 1 WEEK
<filesMatch "\.(jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=604800, public"
</filesMatch>

# Caching for 3 HOUR
<filesMatch "\.(txt|xml|js|css)$">
Header set Cache-Control "max-age=10800"
</filesMatch>

# Caching for 4 HOURS
<FilesMatch "\.(html|htm)$">
Header set Cache-Control "max-age=14400, must-revalidate"
</FilesMatch>

 

Another way to use the “mod_deflate.c” that is one of the best module of apache to speed up your website. Like the other module make sure to enable this module before use the below codes.

# BEGIN GZIP Compression
AddOutputFilterByType DEFLATE text/plain text/html text/xml text/css application/x-javascript application/javascript
# END GZIP Compression

 

Posted by Jogesh Sharma

Jogesh Sharma is a web developer and blogger who loves all the things design and the technology, He love all the things having to do with PHP, WordPress, Joomla, Magento, Durpal, Codeigniter, jQuery, HTML5 etc. He is the author of this blog.