Cross-verb cache invalidation (POST/PUT invalidates GET)

Jonathan Matthews contact at jpluscplusm.com
Fri May 13 21:11:18 CEST 2011


Hi all -

I'm mucking around this weekend designing a "My-First-JSON-API"
service to learn about the process of API design, and I'd obviously
like to make it as cache- and varnish-friendly as possible.

Using HTTP verbs "correctly" (something like the ideas expressed at
http://jcalcote.wordpress.com/2008/10/16/put-or-post-the-rest-of-the-story/)
I'll be POSTing and PUTting incremental and complete objects into the
service and GETting their state - all to and from the same URI per
object.

How can I (and *should* I?) instruct Varnish to obey the TTL that the
backed sets for content received by GETting a specific URI (say
http://example.com/api/object-1/) but to invalidate that content when
a PUT/POST to the same URI is observed?

I've not started poking at it through Varnish yet and, given the
definition of the HTTP verbs in the RFCs, I kind of hope it might Just
Work - that a POST/PUT to a URI will invalidate (and possibly
overwrite with the response body?) the cached content from the last
GET request to that URI.

If not - I throw the question open to the floor ... is this a job that
should be done in VCL? How? Will I just find it done already?

Thanks in advance for any advice!
Jonathan
-- 
Jonathan Matthews
London, UK
http://www.jpluscplusm.com/contact.html




More information about the varnish-misc mailing list