You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A response that returns an empty body (for example, a HEAD request) does not write a cache entry.
Expected Behavior
An empty response body should be written to the cache. (HEAD is useful when looking for redirected responses, for example, but I think it's legitimate to cache empty responses to GET and potentially other verbs.)
Steps To Reproduce
In Node.js
With a default make-fetch-happen instance (i.e. no .defaults())
Run this:
import mfh from 'make-fetch-happen';
const res = await mfh('https://www.google.com/', { method: 'HEAD', cachePath: './cache' });
await res.text(); // "Requests will not be cached unless their response bodies are consumed."
console.log(res.headers.get('x-local-cache-status'));
Observe that the x-local-cache-status header is set to skip, and ./cache/ hasn't been created.
Change HEAD to GET and observe that x-local-cache-status is miss and ./cache is created and populated.
Environment
npm: 10.5.0
Node: v20.12.2
OS: Fedora 39
platform: Linux x86_64
The text was updated successfully, but these errors were encountered:
Is there an existing issue for this?
Current Behavior
A response that returns an empty body (for example, a
HEAD
request) does not write a cache entry.Expected Behavior
An empty response body should be written to the cache. (
HEAD
is useful when looking for redirected responses, for example, but I think it's legitimate to cache empty responses toGET
and potentially other verbs.)Steps To Reproduce
.defaults()
)x-local-cache-status
header is set toskip
, and./cache/
hasn't been created.HEAD
toGET
and observe thatx-local-cache-status
ismiss
and./cache
is created and populated.Environment
The text was updated successfully, but these errors were encountered: