03.31.08
Web pages performance checklist
Here are some principles to follow that will reduce the load on your web server and make web pages appear on screen faster:
- make as few HTTP requests as possible
- concatenate all your CSS into a single file.
- concatenate all your JavaScript into a single file.
- put all your icons into a CSS sprite.
- the filesystem is your friend
- if you have the choice between storing information in the database or on the filesystem, use the filesystem if possible.
- make your URLs predictable
- this is related to (1) and (2). For example, if you have an image with a thumbnail, make the thumbnail URL derive from the image URL. You could, for generality, give the thumbnail an arbitrary URL and have a call to the server to find out what the thumbnail for a given image is called. But why would you want to do that? Much better to put images in (for example) an
images/folder and thumbs in athumbs/folder (or whatever). That way you can avoid unnecessary calls to the server to find out things you should already know. If this seems like a straw-man argument, consider the difference between finding the thumbnail for a youtube video (URL convention) and finding the thumbnail for a google video (pull out an RSS feed and parse the XML to get the URL. Pain.).
- this is related to (1) and (2). For example, if you have an image with a thumbnail, make the thumbnail URL derive from the image URL. You could, for generality, give the thumbnail an arbitrary URL and have a call to the server to find out what the thumbnail for a given image is called. But why would you want to do that? Much better to put images in (for example) an
- avoid talking to the database
- database calls are slow. Making lots of database calls will make you unpopular with your site visitors. Making lots of database calls on shared hosting will make you unpopular with your hosting provider. So…
- use RESTful services with HTTP GET and leverage the caching built into the browser
- print content to the file system if you can
- use
memcachedto store frequently accessed data in memory
- database calls are slow. Making lots of database calls will make you unpopular with your site visitors. Making lots of database calls on shared hosting will make you unpopular with your hosting provider. So…
- don’t listen to me, ask the experts!
- Check the YUI blog articles on performance