Skip to content

Conversation

@peterhuene
Copy link
Contributor

This PR fixes the handling of a 304 response where the server is not responding with the correct headers (e.g. Azure Storage).

A 304 response for a resource should have the same headers as a 200 response for the same resource; when those headers are missing, we error saying that the server said it was unmodified, but the cache says the body needs updating.

Instead of returning an error, we now serve up the stale cached body as the server says it was unmodified. However, as we don't update the stored policy object, a future request for the same resource will always preform revalidation until the server responds with a 200 or a correctly implemented 304.

This PR includes an update to the dependencies and a reformatting of Cargo.toml based on cargo sort.

This commit fixes the handling of a 304 response where the server is not
responding with the correct headers (e.g. Azure Storage).

A 304 response for a resource should have the same headers as a 200 response
for the same resource; when those headers are missing, we error saying that the
server said it was unmodified, but the cache says the body needs updating.

Instead of returning an error, we now serve up the stale cached body as the
server says it was unmodified. However, as we don't update the stored policy
object, a future request for the same resource will always preform revalidation
until the server responds with a 200 or a correctly implemented 304.

This commit includes an update to the dependencies and a reformatting of
`Cargo.toml` based on `cargo sort`.
@acfoltzer
Copy link
Member

Do you have an example of a 200/304 response pair that exhibits this behavior? There is only a limited subset of headers that are required to match what their 200 counterparts would contain (link)

@peterhuene
Copy link
Contributor Author

peterhuene commented Aug 11, 2025

For example, Azure Blob Storage returns an ETag on a 200 and no ETag (or any other header that they're supposed to) on a 304.

There's a 7 year old issue on their feedback page about this...

Copy link
Member

@acfoltzer acfoltzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving for now given the need for these responses to be delivered successfully. I suspect that down the road we'll want to add some logic that treats a 304 as a successful revalidation with a best-effort use of the lifetime-related headers on the original object.

@peterhuene peterhuene merged commit ded7c2e into stjude-rust-labs:main Aug 13, 2025
7 checks passed
@peterhuene peterhuene deleted the fix-azure-error branch August 13, 2025 05:01
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