Rack::Nocache 29 March 2010

So, not for the first time, I've made a gemmings. This one comes out of the sheer rage that repeatedly pressing ⌘-R to refresh a page ignoring the HTTP cache headers [1] causes me.

Basically it just deletes all your carefully crafted cache control headers before sending out the response. I've been using it quietly in dev mode for Rack::Cache based apps for some time now, and it has not harmed me in any way.

Put that in your rack stack (ideally at the bottom) and smoke it.

It's a small gem, and does a small job, and has a small explanation. As such, here is a half-arsed limerick to pad out the article.

There was a gem from Tom Lea,
It deletes cache headers for free.
Use it in dev and it'll be fine,
But be sure remove before go live time,
Failure to do so voids your warrantee.

So it's not quite a limerick, but at least I'm trying!


[1] Seemingly modern browsers (webkit) have started detecting user frustration (repeated, rapid ⌘-R), and use that to decide when to request with no-cache.