Dejan Levec

How to speed up loading of your website

Is your website slow? Do you even realize that it could load faster?

Every webmaster tries to make web sites faster, so people will get better user experience. But there are few tricks that not everyone is aware of.

[b]How to improve loading speed?[/b]
– cache static content (pictures, javascripts, css files)
– remove ETag from pictures
– compress content

First thing is to [b]cache static content[/b] so that it can be loaded from visitor\’s computer and not from server on every visit. Caching will also decrease bandwidth. It\’s good to set expire tag for at least a year.

Every picture sent by a server include [b]ETag[/b] by which browser can check if a picture from a server match picture from browser\’s cache. This is not needed on static content, which will never change (for example, uploaded pictures).

And don\’t forget about [b]compressing content[/b]. Loading will be faster because a browser needs to download a compressed file which is smaller and it will save a little bit of bandwidth. Compression is good for static and also dynamic content (.htm/.html/.css/.js/.php).[b][/b]

[b]Example .htaccess file:[/b]
[quote]Header unset ETag
FileETag None

<FilesMatch “^.*\\.(ico|flv|jpg|jpeg|png|gif|js|css)$”>
Header unset Last-Modified
Header set Expires “Fri, 21 Dec 2012 00:00:00 GMT”
Header set Cache-Control “public, no-transform”

<FilesMatch “\\.(js|css)$”>
SetOutputFilter DEFLATE
You need to put this file in a root directory of your website. Be careful, file doesn\’t have any name, only extension “htaccess”. If you\’re using nice/SEO URLs then there is a good chance of you having this file already in a root directory. Only thing you need to do is to open existing file and copy this example code on the bottom of the file. It will only work with Apache HTTPD Server (most popular http server).

[b]Compressing dynamic PHP file[/b]

To compress PHP file you need to add following code on the top of the file:

Or a bit safer method, that will turn off GZIP compression if visitor\’s web browser doesn\’t support it:
if(!ob_start(“ob_gzhandler”)) ob_start();

You can check [b]site\’s performance[/b] with YSlow add-on for Firefox\’s developer plugin named Firebug.
Download: [url=][/url]

Leave a Reply

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