Opened 2 years ago

Closed 2 years ago

#1851 closed defect (duplicate)

nginx Http2 Push fails when Vary: Accept header set

Reported by: arun-work@… Owned by:
Priority: major Milestone:
Component: nginx-package Version: 1.17.x
Keywords: http2 push, push, http2, vary, vary: Accept Cc:
uname -a: Darwin Roxor-MacBook-Air.local 16.7.0 Darwin Kernel Version 16.7.0: Mon Nov 13 21:56:25 PST 2017; root:xnu-3789.72.11~1/RELEASE_X86_64 x86_64
nginx -V: nginx version: nginx/1.15.8
built by clang 9.0.0 (clang-900.0.39.2)
built with OpenSSL 1.0.2s 28 May 2019
TLS SNI support enabled
configure arguments: --prefix=/usr/local/Cellar/nginx-full/1.15.8 --sbin-path=/usr/local/Cellar/nginx-full/1.15.8/bin/nginx --with-cc-opt='-I/usr/local/include -I/usr/local/opt/pcre/include -I/usr/local/opt/openssl/include' --with-ld-opt='-L/usr/local/lib -L/usr/local/opt/pcre/lib -L/usr/local/opt/openssl/lib' --conf-path=/usr/local/etc/nginx/nginx.conf --pid-path=/usr/local/var/run/ --lock-path=/usr/local/var/run/nginx.lock --http-client-body-temp-path=/usr/local/var/run/nginx/client_body_temp --http-proxy-temp-path=/usr/local/var/run/nginx/proxy_temp --http-fastcgi-temp-path=/usr/local/var/run/nginx/fastcgi_temp --http-uwsgi-temp-path=/usr/local/var/run/nginx/uwsgi_temp --http-scgi-temp-path=/usr/local/var/run/nginx/scgi_temp --http-log-path=/usr/local/var/log/nginx/access.log --error-log-path=/usr/local/var/log/nginx/error.log --with-http_gzip_static_module --with-http_v2_module --with-http_ssl_module --add-module=/usr/local/share/brotli-nginx-module --add-module=/usr/local/share/headers-more-nginx-module


Basically, http2 push using http2_push_preload doesn't work if you set header Vary: Accept on your response because you are doing content negotiation using the Accept request header. I'm using content negotiation to send (http2 push) webp pics instead of jpg to clients that support it.

HTTP/2 Push works for .js, .css files and all in the same call and shows "Push/Other" in Chrome DevTools, but fails for this one unique case (jpg content negotiated to webp), and shows just "Other" (not pushed) in Chrome DevTools.

Content negotiation for brotli, gzip compressions all work fine and get pushed properly using the Vary: Accept-Encoding and same for languages using the Vary: Accept-Language.

Only Vary: Accept fails. Please help I'm at the point of giving up.

P.S: I was going through nginx source Do a Crtl+F and you will find cases for only "Accept-Encoding" and "Accept-Language", nothing for "Accept". So I think "Accept" case is not yet supported by nginx??

P.P.S: I'm not overpushing, only using http2 push for the hero image.

Here is my SO post on the same:

Change History (1)

comment:1 by Maxim Dounin, 2 years ago

Resolution: duplicate
Status: newclosed

Duplicate of #1817.

Note: See TracTickets for help on using tickets.