Skip to content

Do not calculate ETag on POST request - #11345

Open
driusan wants to merge 2 commits into
aces:29.0-releasefrom
driusan:NoPOSTEtag
Open

driusan wants to merge 2 commits into
aces:29.0-releasefrom
driusan:NoPOSTEtag

Conversation

@driusan

@driusan driusan commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator

The ETag middleware currently assumes that it is
handling a GET request and many of our ETagCalculators calculate a strong ETag by hashing the body of a GET request. However, this does not make sense for POST requests. A POST request is not idempotent and is intended to modify the state of the resource it is posted too.

This results in a duplicate GET request being unnecessarily handled to calculate an incorrect ETag for the response to the POST request. In situations like the API candidates endpoint, this can be costly and unnecessary for projects with a high number of candidates.

This changes the middleware to not calculate an ETag for POST requests. The ETag spec specifies that the header can be used for ensuring the right resource is being modified for other HTTP methods such as PUT and DELETE, so only POST is excluded by this change.

The ETag middleware currently assumes that it is
handling a GET request and many of our ETagCalculators calculate
a strong ETag by hashing the body of a GET request. However,
this does not make sense for POST requests. A POST request is
not idempotent and is intended to modify the state of the resource
it is posted too.

This results in a duplicate GET request being unnecessarily handled
to calculate an incorrect ETag for the response to the POST request.
In situations like the API candidates endpoint, this can be costly
and unnecessary for projects with a high number of candidates.

This changes the middleware to not calculate an ETag for POST
requests. The ETag spec specifies that the header can be used for
ensuring the right resource is being modified for other HTTP methods
such as PUT and DELETE, so only POST is excluded by this change.
@driusan driusan added the Category: Bug PR or issue that aims to report or fix a bug label Nov 20, 2026
@github-actions github-actions Bot added the Language: PHP PR or issue that update PHP code label Nov 20, 2026

This branch has not been deployed

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

Labels

Category: Bug PR or issue that aims to report or fix a bug Language: PHP PR or issue that update PHP code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant