Replies: 3 comments 9 replies
|
Unfortunately this wouldn't work. It would allow the toolbar to display, but wouldn't allow the actual editing, because that still needs to send different HTML. It would either need something like an edit query param added to every URL (probably including injecting it into internal links), or use a gateway Worker (which would only work on Cloudflare) that conditionally returns the cached or uncached version depending on the presence of a cookie. |
9 replies
|
@- |
0 replies
|
PR is up: #1886 — implements the two-part design from above (client-rendered toggle from a non-secret localStorage flag, |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Problem
The editor toolbar (the floating pill for authenticated editors) is injected server-side: the
request-contextmiddleware rewrites the HTML response (injectToolbar) wheneverlocals.userhas role >= 30. Since #1398 these toolbar-bearing responses correctly sendCache-Control: private, no-store, so they are never stored in a shared cache.That fix has a structural consequence on any site whose public HTML is served through a shared cache — Cloudflare "Cache Everything" / the new Workers Cache, Fastly, Varnish, Cloudront, etc.:
Vary: Cookiewould fragment the cache into uselessness even where it is honored).no-store) renders never refresh the cache.Today the workarounds are "wait for the TTL" or "add a random query param to force a MISS" — neither is something you can tell an editor with a straight face.
Idea: opt-in client-side toolbar bootstrap
Make the toolbar independent of the HTML variant the cache serves:
emdash-editor=1— no token, no user data; it only means "a session may exist"). Cleared on logout / session expiry.fetchto a smallprivate, no-storesession endpoint (e.g.GET /_emdash/api/toolbar-statereturning{ editor: boolean, editMode: boolean }) and, if the user is an editor, inject the toolbar client-side.no-storeguard from Editor toolbar injection doesn't set Cache-Control: private, no-store, poisoning shared CDN caches #1398 stays for the remaining server-injection paths (preview, edit mode).Scope / design notes
toolbar: "client"), keeping the current server-side injection as the default — zero behavior change for existing sites.emdash-edit-modecookie) already forceprivate, no-storeserver renders and would keep working as they do today; the client bootstrap only covers the "editor browsing the public site" case.fetchthat returns{ editor: false }.<script>.Happy to build this and open a PR if maintainers think the approach fits. Also open to alternatives — e.g. shipping the bootstrap as part of an existing script EmDash already injects, or documenting a recommended cache-bypass pattern instead.
All reactions