I'm researching caching layers for my application stack and seriously considering Varnish. Varnish sounds great, but most of my data is not only dynamic, it also requires authentication to access, and is unique to individual users.
Based on what I've read so far, it seems like there are two options:
When receiving a POST request at the application, I could attach a custom header to the response to Varnish from the origin server, use VCL to parse it, manually expire the existing cache specified by the custom header (usually a GET response to the same resource, in my case), and then strip the header from the response in Varnish before returning it to the user. I'm pretty sure this is possible.
Configure/script VCL to do everything, so when a POST request comes in and a response is returned with status 200, the GET response cache on the corresponding resource is expired. I'm not sure if this is possible.
Basically, I'm wondering:
Is it possible to use VCL to directly force a cached response to expire in the event of a request to a different resource? If so snippets would be much appreciated!
Is there a better way to do this? I don't think I'll have any trouble setting up Varnish to handle caching unique responses, I'll just append the API token to the name of the cache file. What I really need to make this work is a way to let my application force an expiration at Varnish when a user takes an action (POST) that updates a GET.