Skip to content

Add a note about back button and no-cache#44575

Open
tunetheweb wants to merge 5 commits into
mdn:mainfrom
tunetheweb:no-cache-back-button
Open

Add a note about back button and no-cache#44575
tunetheweb wants to merge 5 commits into
mdn:mainfrom
tunetheweb:no-cache-back-button

Conversation

@tunetheweb

@tunetheweb tunetheweb commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Description

Add a section to explain no-cache doesn't mean browsers will always revalidate.

Motivation

Developers are often confused when browsers reuse no-cache pages when they expect them to reload. For example:

This came up again in an internal discussion and we realised this is not documented anywhere.

Additional details

Chrome and Firefox does this as can be seen from this test page.

Safari is difficult to confirm as they agressively use bfcache and everything I've tried to force it not to do that fails. Only no-store stops bfcache from being used by but that is not what I'm trying to test!

Related issues and pull requests

@tunetheweb tunetheweb requested a review from a team as a code owner June 25, 2026 09:38
@tunetheweb tunetheweb requested review from hamishwillee and removed request for a team June 25, 2026 09:38
@github-actions github-actions Bot added Content:HTTP HTTP docs size/xs [PR only] 0-5 LoC changed labels Jun 25, 2026
@tunetheweb

Copy link
Copy Markdown
Contributor Author

@fergald FYI comments welcome!

@github-actions

github-actions Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Preview URLs (2 pages)

External URLs (2)

URL: /en-US/docs/Web/HTTP/Guides/Caching
Title: HTTP caching


URL: /en-US/docs/Web/HTTP/Reference/Headers/Cache-Control
Title: Cache-Control header

(comment last updated: 2026-06-29 23:44:04)

@github-actions github-actions Bot added size/s [PR only] 6-50 LoC changed and removed size/xs [PR only] 0-5 LoC changed labels Jun 29, 2026
@hamishwillee

hamishwillee commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Thanks @tunetheweb - very useful. I've subedited a little to my taste - mostly because I wanted to be even more direct about the unexpected case being the history navigations. I also duplicated the note in Cache-Control, because I think people might also search there.

  1. Are you happy with those changes
  2. Is there anywhere else we should highlight this? I was wondering if maybe also in https://developer.mozilla.org/en-US/docs/Web/API/History_API ?

@fergald

fergald commented Jun 29, 2026

Copy link
Copy Markdown

I could be wrong but I thought this also impacted max-age. Someone said we behave like force-cache here

@tunetheweb

tunetheweb commented Jun 29, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @hamishwillee . I wasn't loving your last sentence (it seems to imply using back DOES use the HTTP cache outside of bfcache), so tweaks that a little further.

I don't think this needs to be on the History API page. It doesn't discuss other caching directives. So think these two pages are sufficient.

PTAL and merge if good!

@fergald I added a similar comment to max-age and must-revalidate sections. It's a little repetitive but think that's the best way.

```

`max-age=0` means that the response is immediately stale, and `must-revalidate` means that it must not be reused without revalidation once it is stale — so, in combination, the semantics seem to be the same as `no-cache`.
`max-age=0` means that the response is immediately stale, and `must-revalidate` means that it must not be reused without revalidation once it is stale — so, in combination, the semantics seem to be the same as `no-cache` (including with above caveat about history navigations).

@hamishwillee hamishwillee Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Lets remove this and put above in note - it is then directly stated it applies.

@hamishwillee

hamishwillee commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Thanks @hamishwillee . I wasn't loving your last sentence (it seems to imply using back DOES use the HTTP cache outside of bfcache), so tweaks that a little further.

@tunetheweb I wasn't loving your last sentence either - very hard to parse. However I've restructured this and I am pretty sure we'll both be happy.

@hamishwillee hamishwillee left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM to me.

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

Labels

Content:HTTP HTTP docs size/s [PR only] 6-50 LoC changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants