Repository navigation
feat: serve the browser runtimes from content-hashed URLs (#578) - #652
Merged
Merged
Conversation
Pages now link Citry's shared runtime as <prefix>/citry.<sha256>.js and the i18n runtime as <prefix>/ext/i18n/runtime.<sha256>.js. Both answer with an immutable one-year Cache-Control, so the browser keeps them between page loads, and a page always loads the runtime it was rendered for. The stable URLs (citry.js, ext/events/runtime.js, ext/i18n/runtime.js) keep serving the current bytes with no-store. - New private module citry/_hashed_runtime.py serves both runtimes; with CitrySettings.cache set, a process that links a hashed URL writes the bytes to the shared cache for 30 days, and a worker serves a stored copy only when its SHA-256 matches the URL. - Citry.runtime_url() returns the hashed shared-runtime URL for hand-written pages. - serialize()/serialize_result() take request_method. Only a page that answers GET or HEAD reloads once when its runtime is missing; the start script and the runtime (for a missing browser plugin) apply the rule. - Every runtime and Events asset 404 sends no-store (and CORS), and the ASGI/WSGI adapters' unmatched-path 404 sends no-store. - Static export, docs-site snapshot assembly, the playground, and the citry_ui quality harness know the hashed URLs. - Design doc docs/design/runtime_hashed_urls.md, spec, design docs, user docs and changelog updated. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…Mechanism 7 (#578) Co-Authored-By: Claude Opus 5.5 <[email protected]>
#578) The maintainer narrowed #578 to the content-hashed runtime URLs. Automatic recovery of a page whose runtime is gone after a deploy is tracked for after 1.0.0 in #665. - A mounted page's start script now calls startDocument when the runtime loaded, and otherwise writes one console.error naming the runtime URL and keeps the server HTML. It sends no request and has one form. - No request_method keyword, canReload value, manifest scriptUrl, HEAD request, location.reload() or session-storage key. client.js, runtime.js, _vue/events.py, serialize.py and citry_render.py match main. - Tests, design docs, the spec, user docs and the changelog follow. Co-Authored-By: Claude Opus 5.5 <[email protected]>
JuroOravec
force-pushed
the
feat/runtime-hashed-urls
branch
from
November 14, 2026 15:22
df34fea to
5899d4c
Compare
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Nov 14, 2026
Merged
JuroOravec
added a commit
that referenced
this pull request
Nov 14, 2026
…ight merged changes (#682) Add one record under docs/security/reviews/ for each of the eight published 0.8.0 advisories (GHSA-4hj5, -8xvf, -7qpw, -g658, -x6rm, -h524, -xmx5, -xg8c) and for each of the pull requests that Mechanism 7, step 7 owes one: #610, #640, #651, #652, #653, #658, #674 and #675. Each record says only what the public pull request, the published advisory, the merged code and its tests show, and lists what was not checked. The reviews README describes how a record for a published advisory differs from a pull request record. The Mechanism 7 list in CLAUDE.md gains the two places that GHSA-7qpw added: parser rules browsers differ on, and the page's declared encoding. Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #578. Design:
docs/design/runtime_hashed_urls.md(merged as #627, updated here to match the code). Targets Citry 0.9.0.Scope. This PR serves the browser runtimes from content-hashed URLs. Automatic recovery for a page whose runtime is gone after a deploy (a reload once, done safely) is left for after 1.0.0 in #665.
What changes
/citry/citry.<sha256>.js,/citry/ext/i18n/runtime.<sha256>.js), served withimmutablecaching. The browser keeps the files between page loads instead of downloading them on every page. The stable URLs (citry.js,ext/events/runtime.js,ext/i18n/runtime.js) keep working withno-store.Citry.runtime_url()is new, for pages written by hand.404withno-storeandAccess-Control-Allow-Origin: *, so the console shows the404rather than a CORS error.startDocumentwhen the runtime loaded. Otherwise it writes oneconsole.error("Citry could not load its runtime: <url>")and keeps the server HTML. It sends no request and has one form, so its CSP hash depends only on the app id and the runtime URL. A missing browser plugin keeps the runtime's existing error. The fragment loader reports a failed runtime the same way.404s for missing Events definitions or stylesheets, and for unmatched paths under the ASGI/WSGI apps, sendno-store.## Unreleased), the docs site builder (hashed runtime in snapshots, shared to the root), the playground and Citry UI quality routes, and the starters' tests all follow.client.js,runtime.js,serialize.pyandcitry_render.pyare unchanged frommain.Checks
test_i18n_client.py::test_javascript_delivery_policy_sees_client_i18n_and_can_omit_it, fails the same way on a cleanmaincheckout here, because the localcitry_corebinary is older thanmain.test_runtime_hashed_urls_e2e.py,test_fragment_e2e.py,test_base_element_e2e.py) on Chromium, Firefox and WebKit: 58 passed, 2 skipped (the prerender case runs on Chromium only).--platform linux.docs build-check: 0 errors. Its 4 anchor warnings (#when-a-script-fails,#when-scripts-run) come from feat(vue): guarantee script order and failure behaviour (#145) #651, not this PR.Review
Two independent reviews found no security hole. The runtime URL in
<script src>, the preload hint, the start script and the fragment loader,Citry.runtime_url(), the digest in the path, the shared-cache entry and the CORS404are all safe, or limited to values the app author sets (the mount prefix). Fixed from the reviews: a leftover sentence about a reload check in the design doc, a stale reason for the CORS header in the spec, troubleshooting matching onUncaught Error, the droppedcitry.js404 row, the stale-citry.jscases, and the changelog and docs wording. A separate prose pass was folded in.Left for the maintainer
CLAUDE.md(commitdocs(claude): list the runtime HEAD check, reload and CORS header in Mechanism 7): the "Requests Citry's browser code sends on its own" and "Page reloads" bullets no longer match this PR and should be removed. The "CORS headers" bullet still holds. I did not editCLAUDE.md.docs/security/reviews/.🤖 Generated with Claude Code