3

One thing I've noticed about CloudFlare and Google's web servers are that they both use lowercase response headers. Is this just for looks, or does it actually provide a performance increase? I'm considering doing it for my custom nginx build, but as of now, I am not exactly sure if there will be any negative/positive consequences. I am aware that the RFC 2616 spec on HTTP 1.1 says that headers are case insensitive, so I am sure that it wouldn't cause any issues otherwise Google and CloudFlare wouldn't be using them.

Example response headers from google.com:

HTTP/1.1 200 OK
status: 200 OK
version: HTTP/1.1
cache-control: private, max-age=0
content-encoding: gzip
content-type: text/html; charset=UTF-8
date: Tue, 22 Jan 2013 20:58:07 GMT
expires: -1
server: gws
x-frame-options: SAMEORIGIN
x-xss-protection: 1; mode=block
5
  • 1
    I can't imagine what performance increase you think you would get by having headers with a different case.
    – Zoredache
    Jan 22, 2013 at 21:05
  • That's what I was asking. There must be some reason that the both of them do that. Jan 22, 2013 at 21:06
  • 1
    No, there doesn't need to a reason any more the to say the developers liked it, or they both use some common library, or piece of software.
    – Zoredache
    Jan 22, 2013 at 21:12
  • Can't you just buy more servers? Jan 22, 2013 at 21:51
  • sigh Yes, you could buy more servers. Jan 22, 2013 at 22:24

1 Answer 1

4

As you pointed out, per RFC 2616 HTTP Headers (indeed, many things in the protocol) are case insensitive.
You can camelCase or InterCap for readability, Or YoU CaN TyPe ThEm LiKe ThIs and annoy anyone who has to debug your HTTP exchanges.

Google and CloudFlare use the SPDY protocol (next to HTTP) which explicitly requires lower case headers.

Lower case characters are faster to type (not requiring a shift key), and may save a whole second in the course of development, but using them will have zero impact on performance - lower-case letters aren't any "smaller" on the wire than upper-case ones.


If you know everything is going to be lower-case you can avoid case-insensitive parsing/comparisons in your software, trading robustness (and RFC conformance) for marginal speed gains.
This is certainly not a GOOD idea though (you don't know what your clients are going to send). I wouldn't muck with the header handling in nginx at all, absent a really good reason to do so. It's been written, it works, and you're more likely to break something than improve anything if you start mucking about with it.

3
  • Did you mean for this to be CW? Jan 22, 2013 at 22:37
  • 1
    yeah, no sense rep whoring when he answered his own question in his question.
    – voretaq7
    Jan 22, 2013 at 23:04
  • > lower-case letters aren't any "smaller" on the wire than upper-case ones. Actually, in some cases they are. When compessed most frequently used characters could end up taking less bits. I would even go as far as saying this may be one of the main reasons they started using it, it saves a couple of bytes per request, but at a Google scale that probably makes a difference.
    – Jan Segre
    Apr 26, 2019 at 3:06

Not the answer you're looking for? Browse other questions tagged .