The GIF-server

Conscious of the need to rationalise the colour scheme of my pages, but reluctant to go through the tedium of recolouring all the little GIF images that make up the corners of the boxes, I decided to let the server take the strain. To this end I've written a little GIF-server CGI script which will supply on demand one of the six little gifs that my pages use and recolour it on the fly.

The GIF-server approach obvously adds the overheads of starting up a thread and compiling and executing the Perl program to the access time of the GIF, but with care it seems to be possible to make these overheads small enough to be negligible. For one thing, the GIF data are stored inline in the program rather than in separate files, which saves another file open. For another, care has been taken not to use any extra Perl modules as these can be very slow to load. In the normal course of things I might have used the standard CGI module and the POSIX time routines, but these are intolerably slow to start up.

Another area of concern is browser-cacheing. I definitely want the images generated by this script to be cached as they are used in several places across the site. Several measures help to ensure good cacheing.

First we try to fool the browser into believing that it is retrieving just an ordinary GIF file.

So a typical query might look like this, http:///gifs/tl-ff0000.gif. In addition we set some other HTTP headers,

This last is absolutely necessary to persuade Internet Explorer to cache the images.

Combined with my perl script for generating the global style-sheet, this should make recolouring my pages a relatively straightforward task - when I finally get round to it. The inevitable end result of all this will no doubt be skinnable pages.

As ever, please let me know if you have any problems with the pages, especially the image cacheing.