Skip to content

Teach Versioned Immutable Asset Caching in the UI Skills - #45

Merged
stevekrouse merged 4 commits into
mainfrom
versioned-assets-skills
Jul 30, 2026
Merged

Teach Versioned Immutable Asset Caching in the UI Skills#45
stevekrouse merged 4 commits into
mainfrom
versioned-assets-skills

Conversation

@stevekrouse

Copy link
Copy Markdown
Contributor

What changed

Three skills now teach the versioned-immutable asset-caching pattern (versionedAssets from std/utils) as the default way to serve client modules:

Skill Change
client-side-js New "Default: versioned, immutably cached modules" section after the per-request-transpilation explanation
http-endpoints Canonical Hono example now stamps + serves versioned assets (plain serveFile kept as unstamped fallback)
react-ui New "Serving assets: versioned + immutable" section with the shell + route snippet

Plus a changeset (patch).

Why

Per-request transpilation means every page load refetches every module. With version-stamped URLs + Cache-Control: public, max-age=31536000, immutable, repeat visits load all assets from the browser cache: measured 665ms → 157ms with zero asset requests. Invalidation is automatic — publishing bumps the val's version, the never-cached shell stamps the new prefix, and stale URLs 302 to the current version.

Prototype: https://www.val.town/x/casual_collab/asset-cache-proto

Do not merge yet

Depends on the versioned-assets branch of the std/utils val merging first — until then versionedAssets is not exported from https://esm.town/v/std/utils/index.ts.

🤖 Generated with Claude Code

client-side-js, http-endpoints, and react-ui now teach the versionedAssets
pattern from std/utils as the default way to serve client modules: the shell
stamps /v<version>/ asset URLs, serve() answers them with Cache-Control:
immutable (302 for stale versions), and publishing invalidates instantly.
Measured: repeat visits 665ms -> 157ms with zero asset requests.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Jul 30, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1f9738f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@valtown/skills Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

stevekrouse and others added 3 commits July 30, 2026 09:32
…mutable/<v>/ scheme

Replaces the versionedAssets() factory (assets.url/assets.serve, /v<version>/ URLs)
with the shipped std/utils API: free functions serveImmutableFile and
immutableFileUrl, the reserved /__immutable/<version>/<path> prefix, and the
frontend/root.tsx shell pattern.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Non-current /__immutable/ versions now 404 (Next.js semantics) instead of
redirecting; both template routes go through serveImmutableFile. Each skill
section slimmed to benefit-first sentence, minimal code, and 2 bullet nuances,
with client-side-js owning the full explanation.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@stevekrouse
stevekrouse marked this pull request as ready for review July 30, 2026 14:12
@stevekrouse
stevekrouse merged commit d14627f into main Jul 30, 2026
1 check passed
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.

1 participant