Code, nerd culture and humor from Greg Knauss.

Sauron has his ring, Voldemort stands victorious, the Yankees win the World Series. Evil triumphs over good. And I have a technical problem.

A couple of weeks ago, on a lark, I wrote a Gresemonkey script to replace the Yankee logo on John Gruber’s Daring Fireball with something more appropriate. I didn’t encode the graphic into the script, instead calling it from a URL, so I could change it as time went on.

The Yankees enter the ALCS:

The Phillies win the NLCS:

The Yankees win the World Series:

All fine and good and totally on the right side of history and moral probity. Except that the baseball season is now over and my little joke should be over along with it, freeing Gruber to change his logo back to the one representing Communist China instead of something that crushes the human spirit. But, um, something like 1,500 people installed the script and because I hadn’t actually planned for mid-October, they’re still going to be requesting a graphic from my site every time they visit Daring Fireball. It’s installed software. You can’t make your users upgrade.

This isn’t an uncommon problem, especially off the Web. You release something, people adopt it, and only then do you start to realize the implications of what you’re now doomed to support for ever and ever and ever.

If I’d been smart — a reach, admittedly — I would have written the script differently, loading the replacement header independently from assigning it to the display, and then not doing the assignment if the replacement wasn’t available. This would have left the normal header in place if my version wasn’t there, with only a query and a 404 response traveling over the network. Elegant! And not what I did.

I had considered putting a date check into the code, to only replace the URL during the post-season. But that hard-codes something that could potentially change, which is always dangerous. Given what they keep doing to baseball, God knows when the post-season will be next year. It just felt wrong.

And so I’m stuck, serving thousands of 7K replacement headers to a site that no longer offends for a joke that’s over. Hijacking part of Daring Fireball in a fit of Yankee-loathing pique is fun, doing it permanently is bad form.

So, OK, absent a time-machine and good sense, there are a few possibilities about how to deal with this:

  • Ignore it. There aren’t that many hits coming from the script, and each only generates a small amount traffic. If I host a proper version of the DF header, nobody will know the difference, probably.

    This is the easiest option, as it’s already done and my hosting plan allows me hundreds and hundreds of gigs of bandwidth that I’m not using. But while ignoring a problem can make sense from a business perspective, the inelegance of it can also stick in my nerd craw like, oh, a Yankee’s World Series victory.

  • Set a long Expires header. Currently, the replacement graphic is only cached for the browser session, so that it will be re-queried often. I didn’t know when circumstances were going to change, and I wanted to be able to update the header as the post-season progressed. With the season over, I could set an Expires header on the image that would keep it locally cached in each visitors’ browser until late September 2010.

    And while this solution solves the network traffic issue, it still requires me to host a version of the normal DF banner, preventing Gruber from changing it arbitrarily, effectively continuing to hijack his site. And again with the hard-coded date issue.

  • Encourage people to upgrade or remove the Geasemonkey script. Ha. While Firefox extensions can be automatically upgraded, Greasemonkey scripts can’t. For a lot of Damned Fireball users, the only time they’ve ever visited my site was to install the script. They’re never coming back, and so would never see an upgrade notice. And even if they did, the vast majority of them would ignore it. That’s just the way users are.

  • Use an HTTP 302 back to the original banner. When the replacement logo is requested from my server, I can respond with a HTTP 302, pointing the browser back to the original, on Daring Fireball’s server. Since that version of the banner is already cached locally (from when the page was originally requested), the only network traffic incurred is the query and a 302 response.

    This “Found Elsewhere” idea is actually pretty good. It keeps the regular expiration of the graphic, so that it can be replaced should the Yankees ever luck into the post-season again, but it also doesn’t incur the traffic of constantly re-sending the replacement banner. It allows Gruber to do what he wants with his original banner since it just returns the browser to whatever was originally downloaded before the script ran.

In fact, this solution is almost as good as if I’d written the code right in the first place.

Which, in software, counts as a victory.

Hi there! My name's GREG KNAUSS and I like to make things.

Some of those things are software (like Romantimatic), Web sites (like the Webby-nominated Metababy and The American People) and stories (for Web sites like Suck and Fray, print magazines like Worth and Macworld, and books like "Things I Learned About My Dad" and "Rainy Day Fun and Games for Toddler and Total Bastard").

My e-mail address is greg@eod.com. I'd love to hear from you!

This site is powered by Movable Type. Spot graphics provided by Thomas, Michael and Peter Knauss.