nitrojs / nitrojs/nitro

"Vary: Accept-Encoding" header is added on every response despite nitro not doing any runtime compression

Open
#3,501 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug static v2
Dominant language
TypeScript
Stars
11.2k
Forks
899
Avg merge
2d 24m
Merged PRs (30d)
40

Description

Environment

node: v20.19.1
nitro: 2.12.4

Reproduction

reproduction

Build the app, preview it, curl the index route and verify that no compression is done by nitro but the Vary: Accept-Encoding response header is added.

Describe the bug

I have a nitro server behind traefik (reverse proxy) that handles gzip compression for me since, as far as I know, nitro does not support runtime response compression (only for static assets) #1007

Everything works fine but I have noticed that the Vary: Accept-Encoding is duplicated on every route response from my nitro server.

Maybe I am wrong, but I believe this header is used by servers to tell caches and proxies that the response changes based on the client's Accept-Encoding header, but nitro will always send the same response (same Content-Length) regardless the client's request.

Why is it adding the header then? Since traefik gzip compression middleware is actually doing the work and adding the header, I get the duplicate.

Is this expected behaviour? Is this a traefik issue?

Thanks in advanced

Additional context

No response

Logs

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked StackBlitz reproduction, build and preview the app, then curl the index route while checking the response headers. Trace where Nitro adds Vary: Accept-Encoding and compare responses with and without compression; done means Nitro does not add the header when it performs no runtime compression, with regression coverage for the observed behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.