All in the <head>

– Ponderings & code by Drew McLellan –

– Live from The Internets since 2003 –

About

hAtom and Last.fm Shoutboxes

26 June 2007

Late last week I received an email from a user of the hAtom to Atom service I maintain at tools.microformatic.com, asking if I could update to the latest version of the hAtom2Atom XSLT that the service implements. Every happy to oblige, this weekend I set about doing just that, and after the upgrade began to tail -f the httpd log so that I could check a few requests to see if the results looked correct.

I’d never really promoted the service in any particular way, and knew that a few people used it for testing their hAtom implementations, as well as using it to subscribe to the odd hAtom enabled page – mostly, I presumed, to keep tabs on their own implementations. You can imagine my surprise, then, to see the log files ticking by and a fair old rate, with URLs from Yahoo! Pipes, but mostly from social music service Last.fm.

A bit of investigation lead me to a blog post describing how to subscribe to a Last.fm shoutbox using my hAtom to Atom service. This is a superb example of the utility of hAtom. Last.fm don’t have a dedicated feed for their shoutboxes, but because they’re nicely marked up with hAtom, it can be converted to Atom on the fly. Awesome.

Now, about my smoking server. At the moment I don’t use any caching on the hAtom to Atom service. Of course, every request to the service causes me to make a request out to the destination server which then does its thing and returns me the result. I take that result and process it and pass it back to my user. Any caching I can implement to cut down that process for common requests seems like the right thing to do – even though I’m not really having any problem serving the volume of requests at the moment.

However, I don’t want to get in the way of those who are using the service as a method of testing their hAtom markup, and an unexpected caching layer could cause havoc there. I’ve considered implementing a no-cache flag, but it’s all too easy for people to forget to remove that or to use it without being fully aware of the implications.

I think what I’ll do is selectively apply caching to known URL patterns (like Last.fm shoutboxes) where I know that retaining the result for 10 or 15 minutes really won’t be a problem, and perhaps drop a comment into the result indicating the time at which it was cached.

- Drew McLellan

Comments

  1. § Ian Phillips:

    It seems that the obvious choice would be to respect the Pragma: no-cache and Cache-Control headers. If people are doing development work they should explicitly disable caching at the HTTP level.

  2. § Drew McLellan:

    That theory is sound, Ian, but in practise it seems most people are making development requests manually via a browser. Under those circumstances there’s not often much control over headers, so I fear it wouldn’t work too well for this.

  3. § Noah Slater:

    Squid to the rescue! If you place an instance of the Squid caching proxy (in HTTP acceleration mode) in front of your application you should see the results you’re looking for – assuming, that is, that you are making correct use of Etags or Last-Modified headers.

    Normal requests (including If-Modified-Since) to a URI would result in a cache hit if the resource was already served by Squid.

    However, and this is the crunch, if the user presses refresh in the browser it triggers a client refresh and Squid will re-fetch the original resource and update it’s cache.

    Sounds like just the ticket.

Photographs

CSS Training Course: 18th July

We're running another CSS course aimed at beginners (or those wanting to freshen up!) on 18th July. Places are limited, so book soon to be sure of a place.

Work With Me

edgeofmyseat.com logo

At edgeofmyseat.com we build custom content management systems, ecommerce solutions and develop web apps.

Recent Links

Affiliation

  • Web Standards Project
  • Britpack
  • 24 ways

About Drew McLellan

Photo of Drew McLellan

Drew McLellan has been hacking on the web since around 1996 following an unfortunate incident with a margarine tub. Since then he’s spread himself between both front- and back-end development projects, and now is Director and Senior Web Developer at edgeofmyseat.com in Maidenhead, UK (GEO: 51.5217, -0.7177). Prior to this, Drew was a Web Developer for Yahoo!, and before that primarily worked as a technical lead within design and branding agencies for clients such as Nissan, Goodyear Dunlop, Siemens/Bosch, Caburys, ICI Dulux and Virgin.net. Somewhere along the way, Drew managed to get himself embroiled with Dreamweaver and was made an early Macromedia Evangelist for that product. This lead to book deals, public appearances, fame, glory, and his eventual downfall.

Picking himself up again, Drew is now a strong advocate for best practises, and stood as Group Lead for The Web Standards Project 2006-08. He has had articles published by A List Apart, Adobe, and O’Reilly Media’s XML.com, mostly due to mistaken identity. Drew is a proponent of the lower-case semantic web, and is currently expending energies in the direction of the microformats movement, with particular interests in making parsers an off-the-shelf commodity and developing simple UI conventions. He writes here at all in the head and, with a little help from his friends, at 24 ways.