0

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!

2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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