Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

1 Answer 1

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

 
discard

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.