Skip to content

Send Cache-Control header with value no-cache - #204

Merged
AA-Turner merged 2 commits into
sphinx-doc:mainfrom
ffplexim:caching
Dec 16, 2025
Merged

Send Cache-Control header with value no-cache#204
AA-Turner merged 2 commits into
sphinx-doc:mainfrom
ffplexim:caching

Conversation

@ffplexim

Copy link
Copy Markdown
Contributor

When modifying a page that is currently not shown in the browser, we noticed that when navigating to it later browsers (especially Safari on macOS) often served the old version of the page that was seen before the update happened. Force-refreshing the page shows the correct content, but this caused confusion for some of my colleagues who didn't think of this right away.

This can simply be mitigated by returning the Cache-Control header with value no-cache (https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Caching#force_revalidation). This makes browsers validate whether the content is still fresh before serving the cached copy, and will ensure that no outdated content is shown when sphinx-autobuild is used.

Related: #196 (I'm not 100% sure I fully understand the problem mentioned there; but the suggested fix there is what this PR implements)

@KyeRussell

Copy link
Copy Markdown

I also believe that this fixes the problem described in #196.

@ffplexim

Copy link
Copy Markdown
Contributor Author

@AA-Turner is something else needed?

@AA-Turner
AA-Turner merged commit c9b7cb9 into sphinx-doc:main Dec 16, 2025
5 checks passed
@AA-Turner

Copy link
Copy Markdown
Member

Sorry, I'd missed this PR.

A

@ffplexim

Copy link
Copy Markdown
Contributor Author

@AA-Turner no problem, thanks a lot for reviewing and merging!

@ffplexim

ffplexim commented Jan 7, 2026

Copy link
Copy Markdown
Contributor Author

@AA-Turner is there a release planned? It would be good to have this fix available in a release.

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.

3 participants