Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple Vary HTTP headers or one combined?

Question: What is the best way to send Vary HTTP header when server accept gzip/deflate connections AND serve a different content for mobile clients?

I see two possible variants but I cannot find any useful information whether they are correct and/or supported by most proxies and search engines:

  1. Combine variants to a single line: Vary: Accept-Encoding,User-Agent
  2. Send two separate headers:

Vary: Accept-Encoding

Vary: User-Agent

Any information or link to appropriate W3C standard are welcome :)

like image 978
WASD42 Avatar asked Mar 01 '15 09:03

WASD42


People also ask

Can a HTTP request have multiple headers?

The HTTP Headers can have one or more values depending on the header field definitions. A multi-valued header will have comma separated values.

Can you have multiple HTTP headers with the same name?

A recipient MAY combine multiple header fields with the same field name into one field-name: field-value pair, without changing the semantics of the message, by appending each subsequent field value to the combined field value in order, separated by a comma.

What is Vary HTTP header?

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.

Can HTTP headers be repeated?

Yes. RFC 2616 Section 4.2 "Message Headers" says: Multiple message-header fields with the same field-name MAY be present in a message if and only if the entire field-value for that header field is defined as a comma-separated list [i.e., #(values)].


1 Answers

Both are valid (and mean the same thing).

And no, the W3C isn't relevant here. You will need to look into the IETF RFCs 7230 and 7231.

like image 112
Julian Reschke Avatar answered Oct 06 '22 23:10

Julian Reschke