Welcome! Log In Create A New Profile

Advanced

multiple vary headers and gzip

Jeff Kaufman
December 12, 2013 11:30AM
In the ngx_pagespeed module we produce css files which refer to either
foo.webp or foo.jpg depending on whether the user agent we're serving
them to advertises webp support in the Accept header. We would like
to serve these publicly cacheable with "Vary: Accept". Because css is
text-based these should also be gzipped when serving to user agents
that advertise gzip in the Accept-Encoding header, which means
including "Vary: gzip".

Currently this means these css files will be served with:

Vary: Accept
Vary: Accept-Encoding

We would rather serve these as:

Vary: Accept, Accept-Encoding

because many user agents don't properly handle multiple headers with
the same name.

We're considering adding code to our module like:

#if (NGX_HTTP_GZIP)
if (r->gzip_vary == 1 && vary_header_already_present(r)) {
r->gzip_vary = 0;
add_accept_encoding_to_existing_vary_header(r);
}
#endif

This is based on the corresponding code from ngx_http_header_filter_module.cc.

This isn't an ideal solution because it couples us more tightly than
we'd like to an aspect of nginx internals we're currently relatively
separate from, but it's the best we have at the moment. Is there
something that would be better for us to do here?

(We also considered trying to add a filter after
ngx_http_header_filter_module that coalesces duplicate headers with
the same name, but it doesn't seem to be possible to modify headers at
that stage.)

Jeff Kaufman

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

multiple vary headers and gzip

Jeff Kaufman 980 December 12, 2013 11:30AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 184
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready