We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The code at
undici/lib/interceptor/cache.js
Lines 235 to 249 in e43d015
import { Agent, fetch, interceptors } from 'undici'; import express from 'express'; const app = express(); app.get('/', (req, res) => { res.set('Cache-Control', 'max-age=1'); res.set('ETag', '"asdf1234"'); res.send({ requestHeaders:req.headers }); }); const dispatcher = new Agent().compose(interceptors.cache({ cacheByDefault: Number.MAX_SAFE_INTEGER, type: 'private', })); let prevEtag; const s = app.listen(4444, async () => { for(let i=1; i<5; ++i) { const headers = {}; if(i == 2) headers['If-None-Match'] = prevEtag; if(i == 3) headers['if-none-match'] = prevEtag; const res = await fetch('http://localhost:4444', { dispatcher, headers }); prevEtag = res.headers.get('etag'); console.log(i, 'res.body:', (await res.json()).requestHeaders['if-none-match']); await new Promise(resolve => setTimeout(resolve, 2000)); } s.close(); });
1 res.body: undefined 2 res.body: "asdf1234", "asdf1234" 3 res.body: "asdf1234" 4 res.body: "asdf1234"
Either:
$ echo "node: $(node --version)"; echo "undici: $(jq -r .version ./node_modules/undici/package.json)"; echo "express: $(jq -r .version ./node_modules/express/package.json)" node: v22.14.0 undici: 7.5.0 express: 4.21.2
There are some other issues relating to cache & case-sensitivity of headers:
Cache-Control
The text was updated successfully, but these errors were encountered:
Thanks for the report!
cache code consistently overwrites user-defined header values
I believe this should be the way to move forward, as these are handled by the interceptor itself and overwrite them can lead to undefined behaviour.
Would you like to send a PR to address that?
Sorry, something went wrong.
I'll take a look 👍
cache: ensure vary & revalidation headers are case-insensitive
6407bbd
Closes nodejs#4103
cache: ensure vary & revalidation headers are case-insensitive (#4112)
fa959b8
Closes #4103 Co-authored-by: alxndrsn <alxndrsn>
Successfully merging a pull request may close this issue.
Bug Description
The code at
undici/lib/interceptor/cache.js
Lines 235 to 249 in e43d015
Reproducible By
Output:
Expected Behavior
Either:
Logs & Screenshots
Environment
Additional context
There are some other issues relating to cache & case-sensitivity of headers:
Cache-Control
header in request #3904The text was updated successfully, but these errors were encountered: