Files
hyperframes/packages
Miguel Angel Simon Sierra a5951da998 perf(studio-server): memoize the built preview document on the project signature
The preview route already returns 304 in under a millisecond when a browser
presents a matching ETag, but it never remembered its own output. Any browser
without a cached copy — every first open of a session, and every gate run —
re-paid the linkedom parse, ensureHfIds and sub-composition inlining, roughly
450ms of the measured preview build at 3,000 clips.

Keep the built document in a small in-process LRU keyed on the same project
signature the ETag is derived from, so freshness keeps exactly one owner: a
cache hit is a document the ETag would have revalidated to a 304. Bounded by
entry count and total bytes, evicting least-recently-used.

The subtle part is the hf-id write-back. persistHfIdsIfNeeded rewrites the
source file when it mints ids, which changes the project signature; the
signature is therefore re-resolved after the stamp and that post-stamp value
now feeds the cache key, the served ETag and the injected signature meta tag
alike. Previously the response carried the pre-stamp ETag, so the second
request disagreed with it and always rebuilt.

The bundle-failure fallback is deliberately not memoized: it produces the
degraded, un-inlined document, is already the cheap path, and caching it would
pin a transient bundler failure until the project changed.
2026-08-03 22:04:02 -07:00
..
2026-08-02 21:57:19 -07:00
2026-08-02 21:57:19 -07:00
2026-08-02 21:57:19 -07:00