Double the Fun
By Randal L. Schwartz
A few months ago, I taught a Perl class at Digital Ink, producers of www.washingtonpost.com. While exploring the site, I stumbled across an interesting image feature: When the page loaded, a rather large, but fast-loading, black-and-white GIF of the image appeared immediately. Then, slowly, the color would magically appear!
I was charmed, and wondered how I could do that. I decided not to look at the source of the page, but to try to figure it out on my own. The basic mechanism I devised is the topic of this month's column.
I guessed that the image wasn't really a single image, but two images, fed into the browser by server push (or "server animation push"). In other words, a special MIME type causes the browser to keep reading multiple versions for the same URL.
I implemented this, but unfortunately, my prototype wouldn't cacheýwhen I returned to the site later, I once again saw the black-and-white preview GIF before reloading the real image. This is unsatisfactory for long-term or heavily used sites.
I investigated further, and discovered that to achieve caching, Digital Ink used the Netscape-proprietary LOWSRC option to the <IMG> tag. This method is clearly superior, as far as server load and user bandwidth are concerned. My script is slightly more portable, however, and there are lessons to be learned from its basic techniquesýso, onward to
|