Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was wondering if it was possible to invalidate cached object by url.

Say i have the url /api/0.1/user and the url /api/0.1/userFriends what i´d like to know, is if there is a way to make /api/0.1/user invalidated when a PUT request to /api/0.1/userMedia is made. However it should only invalidate cache by the http header Authorization. so basically only invalidate cache for the user which performed the PUT request.

I reckon i need a ban configuration to make this work, but im fairly new to varnish, so an example would be greatly appreciated!

share|improve this question

It should be possible. If you have something like this in vcl_recv:

sub vcl_recv {
  if (req.request == "PUT") {
    http.req.x-url = regsub(req.url, "(/api/0.1/user)Media", "\1");
    ban_url("^" + x-url);
    unset req.http.x-url;

This is completely untested. "man vcl" for more info on vcl syntax and semantics.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.