Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"brotli_static on;" causes "Vary: Accept-Encoding" to be added to every file (including images) #97

Open
Jas0n99 opened this issue Apr 7, 2020 · 5 comments

Comments

@Jas0n99
Copy link

Jas0n99 commented Apr 7, 2020

Sorry, bumped my enter key and github submitted this empty... argh... Anyhow, I just noticed this bug.

I have brotli_static enabled at the 'server' level. I just noticed that the "Vary: Accept-Encoding" header is added to things it shouldn't be... Biggest example is images! I noticed all my .png, .jpg, and .gif had that header. I started going nuts trying to figure out what was causing it... Finally when I disabled brotli_static things went back to normal.

Having nginx's gzip_static enabled in the same 'server' context works as expected. Not sure how similar the code is, but maybe there's some inspiration there that could help fix this issue.

This is happening for files directly served by nginx, running 1.17.9

@Jas0n99 Jas0n99 changed the title "brotli_static on;causes "Vary: Accept-Encoding" "brotli_static on;" causes "Vary: Accept-Encoding" to be added to every file (including images) Apr 7, 2020
@Jas0n99
Copy link
Author

Jas0n99 commented Apr 27, 2020

I guess I should add as a clarification that what was happening was brotli_static was adding the "Vary: Accept-Encoding" to file types NOT listed in the brotli_types directive. If that makes more sense.

@dilyanpalauzov
Copy link

Do gzip_static and brotli_static behave differently (taking into account brotli_types and gzip_types)?

Is the Vary only too much for static (pre-compressed) data, or also for run-time (live) compressed data? I mean do
• do gzip_static and brotli_static behave the same in respect to Vary (when gzip_types and brotly_types are the same)
• do broltli on and gzip on behava the same in respect to Vary (when gzip_types and brotli_types are the same)

and thus, is this only related to statically compressed files, or also for dynamically compressed files?

@Jas0n99
Copy link
Author

Jas0n99 commented May 9, 2020

This patch is only relevant when you are using brotli_static on;. With that directive on, all files (even types that aren't specified in the brotli_types) get a Vary: Accept-Encoding header.

If you aren't using brotli_static on;, then everything works fine.

If you only use gzip static on; then it also works fine, and the Vary header is only added for types that are listed in the gzip_types.

Whether the statically compressed file exists or not is irrelevant. It's a logic-error in the static code that was triggering the vary header too soon before doing other checks.

@ktecho
Copy link

ktecho commented Jun 9, 2020

Is there any advance on this issue? I was going to put it into my server, but this scares me a lot.

@Janaka-Steph
Copy link

Regarding brotli_types configuration option, the readme says that it applies to on-the-fly compression, not static files.
https://github.com/google/ngx_brotli#brotli_types

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants