Web Talk

Search

Web Talk, WebmasterComments Off on How to boost your website performance by using .htaccess to cache it

As a webmaster, one of the biggest worries of mine as far as my blog is concerned is, without any doubt, its performance, namely the ability to be downloaded in any browser in almost no time (yes, I am a bit ambitious!). As a matter of fact, the more your website is accessible the more people will be able to see it, above all those ones who have a slow Internet connection such as dial-up or ISDN connection (and believe me, there are a lot of them, more than you think!). There are a lot of techniques and open source, freeware software that can help you to achieve this result, just browse my Webmaster section to find out more. Anyway, what I didn’t know till yesterday, was that I could get amazing results just by using some nice piece of code to copy-and-paste directly in the .htaccess file located under the public_html folder.

The techniques I am going to write about involve the caching of your blog. But what does it mean? Basically, when a visitor reads a page in your blog, his browser caches its content in your server. Every time the visitor uses the cache, his browser will send a “301” which is nothing else than a redirecting instruction to verify if that page has been changed. As you can well imagine, this is quite time and resource consuming, both for your readers and your server. That’s why we can instruct the browser to cache the page for a longer period of time, above all for those files such as: images, MP3, javascript etc. which will to stay the same for a certain period of time.

The code below needs mod_headers enabled in your server. If you don’t know if it is enabled or not, just ask your server provider. Here is the code to copy-and-paste in your .htaccess file.