Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I Vary on a custom header?

I'm bucketing User-Agents by device using something like varnish-devicedetect and storing the result in X-UA-Device on the request and the response.

I've seen several recommendations to vary on User-Agent. Any reason not to vary instead on X-UA-Device? Seems like it'd be nicer to downstream caches.

like image 556
hurrymaplelad Avatar asked Jan 11 '14 00:01

hurrymaplelad


People also ask

What is vary in headers?

The Vary HTTP response header describes the parts of the request message aside from the method and URL that influenced the content of the response it occurs in. Most often, this is used to create a cache key when content negotiation is in use.

What does vary accept encoding mean?

What Does “Specify a Vary: Accept-Encoding Header” Actually Mean? Accept-encoding header is an HTTP header which must be included on every origin server response. Its main job is to inform the browsers if the client can handle the compressed version of the website.

What does vary origin mean?

Vary: Origin When a user agent receives a response to a non-CORS request for that resource (for example, as the result of a navigation request), the response will lack `Access-Control-Allow-Origin` and the user agent will cache that response.

What is a custom header?

Custom headers allow site owners to upload their own “title” image to their site, which can be placed at the top of certain pages. These can be customized and cropped by the user through a visual editor in the Appearance > Header section of the admin panel. You may also place text beneath or on top of the header.


1 Answers

Since X-UA-Device is not available on the client request or in any downstream proxys (it's generated inside Varnish) you have to vary on the raw User-Agent header.

like image 69
NITEMAN Avatar answered Oct 18 '22 10:10

NITEMAN