views:

135

answers:

5

Hi Everyone

I have a few sites I built for my work, nothing major, mainly just little tools which people can access and use when they're out of the office. I'm not very experienced as a developer but I like to tinker quite a lot and I was wondering if anyone had any clever little tweaks I could do to my sites to make them download faster? We have an office in south america with a poor internet connection who constantly complain my sites take too long to use. So far I have found the following site which was quite useful and the guys in the other office said they'd seen a difference in the service www.dev-explorer.com/articles/apache-optimisation

Anyone kno of any more little bits and pieces I could do?

Any help is much appreciated.

Thanks in advance

John

+6  A: 

Look into YSLOW and read the Yahoo Dev blog. You can do a lot by optimizing the front-end.

  • Limit the number of http requests (css, js, images)
  • Use mod_deflate in apache to gzip your content
  • Use a far-future expires header whenever possible
  • Make your HTML markup as lean as possible
jonstjohn
...and tune your DB
vladr
A: 

Hi

Thanks for the immediate reply.

Those are things I've already done (stuff I got off that site) I was wondering if anyone had found other little things I could try.

I've just checked out yslow by the way and downloaded their firefox plugin and that should at least help me test whether what I'm trying works. Its quite difficult to test since I'm always working in the same building as the sites are hosted so for me they're super quick.

Thanks again John

A: 

A few simple tricks:

Firstly, limit yourself to exactly one CSS and one Javascript file. No more. If you have multiple compact them into one (each). Ideally, your Javascript should also be minified. I've been using JSMin for this lately.

There are some more advanced techniques to optimize this further. You set the expires header to far in the future so the browser doesn't download it as often. To push changes you need to change the link to the css/js file though. You can do this with Apache mod_rewrite and a small PHP script.

More on this in What is an elegant way to force browsers to reload cached CSS/JS files?

You can also use the expires trick on images.

Secondly, gzip your constent. Typically all you have to do for this in PHP is start all your scripts wiht:

ob_start('ob_gzhandler');

This turns on output buffering (good idea anyway) and if the browser says that it supports gzip encoding, your script will be gzipped before sending it to the client.

cletus
+1  A: 

2 things (from YSlow) that will help are a CDN (Content Delivery Network)... and cookie-less servers for static content.

Even if you can just push your images to load off another server you'll be able to load your HTML content faster while image downloading can happen in the background from the other server(s).

Try to have these other servers (for images, CSS, and Scripts) be cookie-less if possible, its a minor saving, but it sounds like you're trying to squeeze every last drop. ;-)

and of course, cache everything except your HTML.

scunliffe
+1  A: 

I'd got for yslow, as already said, and better (because is what yslow is based on) the Yahoo Exceptional Performance Team best practices

kajyr