By reducing the file size of your CSS, JavaScript and images, as well
as the number of unnecessary browser requests made to your site, load
time of your applications pages can be drastically reduced, not to
mention the load on your server.
Yahoo have created a list of the
35 best practices
to speed up your website, a recommended read for any web developer. I
wanted to summarize a few I recently implemented in a Django
application.
In a nutshell:
-
Serve compressed static media files. This one is obvious, the smaller the file size, the quicker it is to download.
-
Once a browser has already downloaded the static media, it shouldn't
have to download it again. This is what actually happens, as the server
will respond with 304 Not Modified, which means that the cached file is still up-to-date.
-
However, the HTTP request is still sent. This is unnecessary and
should be avoided by setting the HTTP Expire header to a date in the
future.
-
When files are updated, you need to give them a new URL so the browser
will request them. This is referred to as versioning. A common scheme
is to use the modification time/date of the file in its URL, either as
part of the name or in the query string. This is obviously tedious and
error prone, so automation is required.