ZedneWeb
e + 1 = 0

Freshness-dating ZedneWeb

By Dave Menendez
Tuesday, October 21, 2003, at 11:33 PM
Filed under: ZedneWeb

Summary: A neat little extra (well, I think it’s neat): ZedneWeb entries now indicate how long ago they were posted.

A while ago, I noticed a few web logs which indicated how long ago a post was published. It’s a neat idea, because it lets readers gauge a post’s freshness in a fairly straightforward manner. At the time, though I figured it had two disadvantages:

  1. It requires dynamic page creation in order for the page to indicate how old it is. That’s out of the question here at ZedneWeb, as all the pages are served statically.
  2. It modifies the pages even though they haven’t really changed. Among other things, this defeats caching. (Granted, web caches are something of an urban legend in the HTTP world, but it’s the principle that matters.)

Having concluded that I (a) couldn’t do it, and (b) shouldn’t do it, I went my merry way.

Until last night, when I suddenly realized I was wrong. My content manager puts a date on every ZedneWeb post, in the vain hope that it might prove useful to some content aggregator out there. Thus, I could write a script that would take that information, compare it to the current date, and insert a freshness statement into the page—and do it all in the browser.

So I did. My Javascript’s a bit rusty, so I’m sure the code can be cleaned up, but it works in the small suite of tests I’ve run. This is one of those cases where the scripting is purely extra, so people who have scripting disabled or whose browsers choke on my code aren’t missing anything important.

For fun, I’ve also put a script on the monthly calendars which highlights the current day. It’s not useful, and I suspect no one will ever see it, but why not? If nothing else, the experience may come in handy some day.