Making decisions based on HTTP headers
Last updated
Was this helpful?
Last updated
Was this helpful?
One of the advantages of using Varnish is its versatility, allowing us to make decisions based on any header that comes in the web request.
While we previously saw how to block content by or by it is equally easy to make decisions of any kind based on the value or mere existence of an HTTP header.
Just as we explained how to choose one backend or another based on a URL or host, it is equally simple to do it based on a header, for example, the .
This is especially useful when you need to restrict access to your site for any reason but don't want to protect it with because that would prevent the site from being cached.
This mechanism is very useful, but you need your browser to include that HTTP header in each request for your navigation to work. To do this, we recommend installing the Chrome extension.