Skip to content

feat: allow conditional revalidation for QUERY requests#7366

Open
Cherry wants to merge 1 commit into
expressjs:masterfrom
Cherry:feat/fresh-query-method
Open

feat: allow conditional revalidation for QUERY requests#7366
Cherry wants to merge 1 commit into
expressjs:masterfrom
Cherry:feat/fresh-query-method

Conversation

@Cherry

@Cherry Cherry commented Jul 7, 2026

Copy link
Copy Markdown

req.fresh only performed weak freshness validation for GET and HEAD, so responses to QUERY requests never returned 304 Not Modified even when the client sent a matching If-None-Match. This extends the method guard to include QUERY.

-  // GET or HEAD for weak freshness validation only
-  if ('GET' !== method && 'HEAD' !== method) return false;
+  // GET, HEAD, or QUERY for weak freshness validation only
+  if ('GET' !== method && 'HEAD' !== method && 'QUERY' !== method) return false;

As far as I can tell, QUERY is a safe, idempotent, cacheable method whose responses explicitly support conditional revalidation, as per https://datatracker.ietf.org/doc/rfc10008/, so it should behave like GET/HEAD here.

I've added tests where it makes sense, and would also be happy to backport this to v4.x if accepted.

Fixes #7365

req.fresh only validated freshness for GET and HEAD, so QUERY responses never returned 304 despite a matching If-None-Match. QUERY is a safe, idempotent, cacheable method that supports conditional requests, so include it in the freshness check.
@krzysdz

krzysdz commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

cc @jonchurch (initial work on QUERY support) @blakeembrey (fresh captain)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

req.fresh returns false for QUERY requests, so 304 Not Modified is never sent

2 participants