Brent added support for Etags and If-Modified-Since headers to the la NetNewsWire beta. It's very cool. He added it after hints and pressure from among others Joel, Phil, Sam and Mark; I'll refrain from pointing out that I suggested it to him several months ago, although my justification was to make it faster for people on slow connections. :-) I noticed in my logs that a new version of Radio Userland is doing the right thing too.
Charles Miller wrote "HTTP Conditional Get for RSS Hackers". In his section about dealing with it on dynamically generated pages he suggests to just do a string comparison between your calculated last modified date and whatever you got from the client. But why, I cry! It is so easy to do it right.
If you have access to the Apache API in your environment (for example through mod_perl), you can just set r->last_modified (you have to do that anyway to make anything work at all) and then do something like
if ( (my $response_code = $r->meets_conditions) != 200) {
return $response_code;
}
And Apache will magically take care of comparing date and Etag headers for you. How cool is that? mod_php, mod_python and the other Apache API interfaces should expose that function too. If not, go and send a patch already! :-)
Update: I just remembed that Andreas König wrote a great document on Issuing Correct HTTP Headers. It covers more details about doing this correctly for dynamic content without making you yawn at the SHOULD, MAY and MUSTs of the RFC.
Update 2: I keep reading people suggesting to do a HEAD before the GET. What kind of stupid idea is that? In this context HTTP can do everything you you need in the GET request; saving you an extra request when the feed is updated. (URL's surpressed to protect the ignorant and the guilty).
When cut'n'pasting the title from Charles' post I noticed a really neat thing about using CSS to uppercase titles: They are cased properly when cut'n'pasted... Neato!
Oh, and Doonesbury continues to be Too Much Fun this week. Again. Start with the entry I referred to Monday.
PS. I wish I could explain why I choose todays photo of a Happy Duck, but I can't. :-) It's from San Diego Zoo some months ago.
one situation when doing a HEAD before a GET isn't such a stupid idea is with dynamic content that takes significant time to generate, e.g. difficultdatabasereport.pl?yyyy=1997
Adam,
No. If you use the If-Modified-Since/Last-Modified headers then the GET request will Do The Right Thing.
- ask