However, Cherokee didn’t always try its hardest to serve us well: sometimes it decided to pull the server’s load to a performance-decreasing number, configuration of much needed features was “not yet implemented” or buggy and the software is overall not done yet. Also, the developers have, weirdly, decided to use exclamation marks as separators within the configuration, which is just plain annoying.
So we started looking towards other solutions. And we decided to go back to our other option before we chose Cherokee: Lighttpd. With Lighty, as it’s pronounced, we can apply these performance rules:
I’d like to show you which configuration options we used. The following applies to a default Lighttpd (version 1.4.19) as shipped with Ubuntu 8.10. If you’re using a different OS or if you’ve downloaded Lighttpd yourself, I assume you understand enough of it to translate the following to your own situation.
Add an Expires or a Cache-Control Header
For this, we need mod_expire. With that module, we can instruct Lighttpd to include both the “Expires” and the “Cache-Control” headers in the response. To enable the module, we uncomment this line:
This line is mentioned in a list of modules at the top of lighttpd.conf. If it’s not, you should look for the list somewhere else in the file and uncomment the line or simply add it, but without the hash sign.
Next, look up a line that says ‘expire.url’. It should be there and commented by default. Uncomment it and configure it to do what you want it to do. For us, Lighttpd is entirely dedicated to serving static files, which all need to be cached by the client for a long time. Let say, for documentation’s sake, we choose two weeks as the caching time. This would then be our configuration:
expire.url = ("/" => "access plus 14 days")
This leads to these two headers when a URL from the Lighttpd-server is requested:
Expires: Thu, 25 Dec 2008 13:30:31 GMT
And that’s it! Enable the ‘expire’ module, configure the expire time, and you’re done.
To apply gzip encoding of the repsonse body, we use mod_compress, which is enabled and confgured by default. However, not everything we want to compress is actually being compressed, so we change this:
Over time, we might add other mime-types we forgot to include, but the above covers most of the requests.
When requesting an image with any regular browser, it will be sent to us, gzip-encoded. If you’re using FireFox with the Live HTTP Headers extension, you can find these in the response headers:
This confirms that it’s working.
This is the easy one. In our default installation, a request to the server gave us this as one of the response headers:
Last-Modified: Wed, 10 Dec 2008 13:16:32 GMT
Because we currently use one server for the static serving, this is all we want. So we’re done.
And that concludes the confguration of Lighttpd as the optimal static-files-webserver.