0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-05 23:04:22 +08:00
discourse/app/views/layouts
Régis Hanol f5cd83cab6
FIX: Prevent browsers from restoring stale documents in bfcache mode (#42207)
Previously, enabling `cache_control_bfcache_compatibility` (the
experiment currently running on meta, #38763) made HTML documents
storable in the browser HTTP cache, and browsers skip revalidation on
history navigations — so back/forward, session restore, and
discarded-tab reloads could resurrect a days-old document: stale topic
lists that only get older, and logged-in UI shown to logged-out sessions
(and vice versa). Reported in https://meta.discourse.org/t/400459.

This change keeps the documents out of shared caches (`no-cache,
private`), reloads any document that was served from the HTTP cache on a
history navigation (navigation entry with `type === "back_forward"` and
`transferSize === 0` — a forced reload gets type `"reload"`, so it
cannot loop), and validates the session on `pageshow` restores from the
back/forward cache, reloading when the logged-in user no longer matches
the one the page booted with. Both client-side checks only run when the
setting is enabled; the full rationale (browser-engine specifics, why
`transferSize` rather than `deliveryType`, why `fetch` rather than
`ajax`) is in the commit message.

Reproduced and verified end-to-end in Chromium and Firefox: with the
setting enabled, `goBack()` served `/latest` with zero network contact —
stale list, wrong login state, and the exact `403
/u/:username/private-message-topic-tracking-state` errors from the meta
report; with this change the same navigation heals with a single
automatic reload, and a control run with the setting disabled behaves as
before.
2026-07-31 17:24:47 +02:00
..
_head.html.erb FEATURE: beacon-based implementation for BPV (#38897) 2026-04-15 16:32:05 +03:00
_noscript_footer.html.erb
_noscript_header.html.erb
_plugin_js.html.erb DEV: Improve plugin js loading logic (#38278) 2026-03-05 14:18:40 +00:00
application.html.erb FIX: Prevent browsers from restoring stale documents in bfcache mode (#42207) 2026-07-31 17:24:47 +02:00
crawler.html.erb FEATURE: Append locale to links in crawler view if present (#34466) 2025-08-22 08:46:33 +08:00
email_template.html.erb UX: add preview to email templates (#36657) 2026-01-08 11:33:53 +04:00
embed.html.erb DEV: Replace JS build system with Rolldown (#35963) 2026-05-29 11:11:55 +01:00
finish_installation.html.erb DEV: Allow new instances to be set up directly with Discourse ID (#36731) 2025-12-23 12:13:36 -05:00
no_ember.html.erb DEV: Replace JS build system with Rolldown (#35963) 2026-05-29 11:11:55 +01:00
publish.html.erb DEV: Replace JS build system with Rolldown (#35963) 2026-05-29 11:11:55 +01:00