Caching vs GET idempotence

The simplicity of caches_page and kin is brilliant, and I use them liberally. But recently I've been encountering a subtle problem.

Since version 2.2, Apache has begun issuing intermittent GET requests to itself. They hit the root '/' url. Since they come from a local source, request.domain is some variation on, which mean that all your url_for-constructed links point to localhost. Which is fine, because Apache's 'internal dummy connection' doesn't look at the response. But if your home page cache had just expired, the new cached version that will be served up to all visitors has a bunch of bad links...

On our blog I have listed a snippet of Apache configuration[1] that sends these internal requests a harmless 403. I'm sure there are much better solutions. Furthermore, there's no question that Apache's behaviour is a bit obnoxious. But it is premised (like GWA, but to a much lesser degree) on the idea that GETs should be idempotent, and Rails' on-demand caching pattern transgresses this principle.

Or does it? I'm happy with a pragmatic trade-off, but what do the purists on the board think?


- J