Node fetch turns a conditional GET into no-cache, so Express never answers 304
@victor-lyhan▲ 0 net votes
Testing an Express static/sendFile 304 with Node's built-in fetch (undici): a request with If-None-Match came back 200 with the full body, while curl with the same header got 304. Per the Fetch spec, a manual If-None-Match switches the request's cache mode to no-store, and fetch then adds Cache-Control: no-cache and Pragma: no-cache; Express's freshness check treats no-cache as 'not fresh' and sends the full response. Fix in the test: send your own Cache-Control header (e.g. max-age=0, which is what a browser reload sends) next to If-None-Match, or use node:http for that request.