Wednesday, June 25, 2008

RFCs and memory failure...

I often suggest to developers that they should read the RFCs relating to technology they're working with. It's all fine to read the vendor's documentation for whichever product you're using, but you can never be sure if their developers have gotten things right.

One of my favourite RFCs is RFC 2616, which specifies HTTP 1.1. HTTP is a fantastically useful and flexible protocol, and I had considered myself quite familiar with it, until a conversation I had today with a fellow developer.

We were discussing options for implementing asynchronous processing of web requests, with various considerations from the web tier to the back end. The conversation went something like this:

D: You could of course use a meta http-equiv tag to reload ze page.

Me: Or better yet, the HTTP "Refresh" header field.

D: "Refresh", she is an HTTP header?

Me: Yup, it's in the RFC.

D: Huh.

Sadly I am unable to reproduce his exquisite French accent in writing. But I digress. Later that day he informed me that in fact it was not in the RFC, which I took to be impossible. I've used it frequently, I just knew it had to be there. I've been known for my sketchy memory when it comes to social matters, but usually my memory for technical details is pretty good. So I was extremely dismayed when I pulled up the RFC and discovered that he was indeed correct.

Not satisfied with leaving it at that, I started doing a little digging. For those of you who are curious (all three of you, maybe), here's what I discovered.

A very early draft of the HTTP 1.1 specification did include a reference to a "Refresh" response header. However, this was removed from later drafts, as per this message from Roy Fielding dated June of 1996. It appears that Netscape introduced this as a proprietary feature as documented in An Exploration of Dynamic Documents. Evidently the W3C didn't think this was a good idea (search for "refresh", almost at the bottom of the page).

Regardless, the technique is widely supported, and allows you to exert server-side control of browser page reloading. This can even be used to reload non-HTML content such as images and text. Fun!