Skip to content

fix: let a wildcard If-None-Match take precedence in date-only conditional routes - #1881

Merged
He-Pin merged 1 commit into
apache:mainfrom
pjfanning:fix-if-none-match-wildcard-date-only
Nov 29, 2026
Merged

He-Pin merged 1 commit into
apache:mainfrom
pjfanning:fix-if-none-match-wildcard-date-only

Conversation

@pjfanning

Copy link
Copy Markdown
Member

Follow-up to #1868, covering the gap I noted in my review there.

Problem

conditional(lastModified) (no ETag) with a request carrying If-None-Match: * fell through to the If-Modified-Since step. RFC 9110 §13.1.3 says If-Modified-Since must be ignored when If-None-Match is present, and §13.1.2 says the wildcard condition is false whenever the server has a current representation.

Change

In step 3 of conditional, when the request has If-None-Match: *, no ETag is configured and a modification date is configured (so a current representation is known to exist):

  • GET and HEAD get 304 Not Modified, regardless of If-Modified-Since.
  • Other methods get 412 Precondition Failed.

This matches what the directive already does for the wildcard when an ETag is configured. When neither an ETag nor a modification date is given, behaviour is unchanged.

Behaviour change to be aware of

A PUT/POST/DELETE with If-None-Match: * through a date-only conditional previously reached the inner route and now gets 412. That is the point of the wildcard (create only if absent), but it is visible to applications.

Tests

Added cases to CacheConditionDirectivesSpec for GET and HEAD (304 even when If-Modified-Since alone would select the representation), PUT (412), and the unchanged no-validator case. Ran that spec and the scalafmt checks for the two touched modules locally; the rest is left to CI.

🤖 Generated with Claude Code

…ional routes

Follow-up to apache#1868. With only a modification date configured, a request with
If-None-Match: * fell through to If-Modified-Since. The wildcard matches any
current representation and If-None-Match takes precedence over
If-Modified-Since (RFC 9110 sections 13.1.2 and 13.1.3), so GET and HEAD now
get 304 and other methods get 412.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@He-Pin
He-Pin merged commit 524763e into apache:main Nov 29, 2026
6 checks passed
@pjfanning pjfanning added this to the 2.1.0 milestone Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants