In May 2001, ColdFusion Developer’s Journal published my article “Spectra Calamari,” with the subtitle “Squid’s Web proxy cache.” It’s in Volume 3, Issue 5, starting on page 52.
I was still the web site administrator at Plattsburgh State. We had bought Allaire Spectra for its content management features. Spectra was less expensive than its competitors but it wasn’t cheap, and Allaire’s own capacity white paper recommended at least two dual-processor front-end servers, each with its own license. The article puts that at roughly $20,000 a server. We didn’t have that budget.
It was a stressful time. We’d invested in the Allaire stack. Allaire sold Spectra as a content management toolkit, and the marketing material wasn’t entirely clear. I took that to mean a turnkey CMS, and I was a bit surprised to learn I’d have to build it. I’d spent a fair amount of time building a content management system for the university on Spectra and had migrated all our pages into it. When I went to turn it on, it could serve only two or three users at a time before it bogged down. Failure wasn’t an option. I had to find a way to make it work.
What I found was Squid, a web proxy cache. Squid is normally used inside a company to cache popular pages from the Internet and cut down on outbound traffic. It can also run the other way, in what it called httpd-accelerator mode, sitting in front of one web server and answering requests for it. That’s how I used it. Squid became our “production” server and Spectra effectively became the “development” server, at a much lower cost than a second Spectra box.
The article is a setup guide: building Squid on Red Hat 6.2, a minimal squid.conf, using Squid’s access control lists to restrict ports and hide directories like cfide and cfdocs, and running, testing, tuning and maintaining the server. Squid also let us put the web server behind the firewall.
The tricky part was getting Squid to cache ColdFusion pages at all. It wouldn’t until the web server sent a cache-control header, which I set in IIS with max-age=3600 as a default. Then I had to take the header back off the directories that shouldn’t be cached. I wrote that I was puzzled by bizarre behavior from the server before it dawned on me that I was getting cached pages where I wasn’t expecting them.
Caching had costs. Spectra’s personalization needed a live connection between browser and server, and with Squid in front, every request looked like it came from the same client. Spectra’s built-in logging no longer reflected real traffic. The hardest problem was browser sniffing. I’d done it in application.cfm, Squid cached the results, and I had to redo it in JavaScript.
For us it was worth it. The site was mostly static, nothing changed more often than every few hours, and moving most requests off Spectra freed it up for our content developers. In effect we gained another Spectra server.
Squid was a fantastic solution, and implementing it saved the day. It was also the start of my fascination with content management systems, and it taught me a valuable lesson: don’t roll your own. There are too many moving parts and too many threads to pull. But I was younger and didn’t know better.