Skip to content

Keep cached status after 304 revalidation in req_cache() - #897

Open
m-muecke wants to merge 1 commit into
r-lib:mainfrom
m-muecke:fix/cache-304-status
Open

m-muecke wants to merge 1 commit into
r-lib:mainfrom
m-muecke:fix/cache-304-status

Conversation

@m-muecke

@m-muecke m-muecke commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@hadley

hadley commented Oct 8, 2026

Copy link
Copy Markdown
Member

It's been a while since I thought about this, so would you mind walking me through the logic here?

@m-muecke

m-muecke commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor Author

This keeps the cached response's status after a 304 revalidation. Before, the first request returned 200, but from the first revalidation onwards every request returned 304. This follows RFC 9110 §15.4.5: a 304 means the stored copy should be used "as if it were the content of a 200 (OK) response". But the wording isn't quite clear on the status code, so I think it can go either one and this can be closed.

most libs seem to be following it as far as I can tell: OkHttp, requests-cache and Go's httpcache

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants