Software As She’s Developed

Mahemoff’s Podcast/Blog - Web, Programming, Usabilty from the Author of ‘Ajax Design Patterns’ (AjaxPatterns.org)

Software As She’s Developed header image 2

Digg API - Can’t Bust the Cache

June 30th, 2007 · 2 Comments

It’s often a requirement for an Ajax app to “bust the cache”, i.e. call a service and ensure its response comes direct and not from a cache. For all the talk of fancy header techniques, the easiest way to do it is by appending an arbitrary parameter, typically a random number and/or a timestamp i.e. call service.com/?random=39583483. I use this pattern not just as an Ajax programmer but also as a user; when I suspect my wiki page or blog is cached, I just add an arbitrary parameter and usually get the most recent result.

With Digg API, that’s impossible. I just tried it and discovered you get an unrecognised argument error if you pass in a parameter they weren’t expecting. This is well-intentioned as it will give early failure advice to callers who mistype or misinterpret parameter names. But unfortunately, it has the major downside of breaking this convention and thus breaking compatibility with a large number of toolkits that exploit this pattern.

I discovered this as I was writing a Google Gadget to show Digg stories and when you fetch content with the Google API IGFetchContent(”http://digg.com/….”, callbackFunc, { refreshInterval: 60 }) - the refresh option apparently leads to Google tacking on an arbitrary parameter called “cache” (it’s impossible to be sure as it’s proxied via Google, but the argument to that proxy is the Digg URL with “cache=” on the end). Net effect: I can’t update Digg stories any more than once per hour. The only way I could do it would be to write my own proxy and cache. A lot more work than the one-liner IGFetchContent call! Yeah, like that’s gonna happen.

For the Digg API, perhaps they need to introduce an optional “strict” parameter like a compiler offers to give extra debug info. If it’s off, then let anything through.

Categories: SoftwareDev

Tags:

2 responses so far ↓

  • 1 Michal Migurski // Jun 30, 2007 at 4:25 pm

    I’ll talk to Steve about this. It’s stupid for Google to go tacking on extra crap to a URL (who are they to determine that “cache=” is a harmless add?), but those are the breaks.

  • 2 mahemoff // Jun 30, 2007 at 5:13 pm

    Thanks Michal, that would be appreciated. In an ideal world, both Google and the web services would make the extra param optional.

Leave a Comment