ReviewOS

stacks/stx

feat(rendering): unify per-route rendering and cache policies across build and production serving

#1966
Closed glennmichael123 opened this 10 days ago ·
10 days ago

Problem

stx has SSR, SSG, and createISRHandler, but applications lack a unified route-pattern configuration connecting these capabilities across build and production serving.

An application should be able to prerender landing pages, cache public blog pages with background revalidation, and keep account pages dynamic through one documented configuration.

Existing foundation

Reviewed at 7d93c4c: ssg.ts, production-server.ts, and config types. This is integration work around existing rendering/cache machinery, not a claim that ISR is missing.

Scope and acceptance criteria

  • Introduce typed per-route rules with documented pattern matching and precedence.
  • Initially cover prerendering, dynamic rendering, cache lifetime, and background revalidation.
  • Connect the rules to both build output and the production request handler.
  • Ensure full-page and SPA-fragment responses follow consistent policies without mixing their cache entries.
  • Keep personalized responses out of shared caches by default.
  • Verify precedence, cache hits, expiration, revalidation failures, and explicit invalidation.
  • Document supported combinations and reject unsupported settings clearly.

CDN-specific ISR and additional deployment platforms can remain follow-ups.

Prior art: Nuxt rendering modes and route rules.

10 days ago

Implemented in d50692d. Typed routeRules now flow through production builds and manifests into the request handler, with deterministic precedence, prerendering, opt-in bounded anonymous caching, TTL/SWR, refresh-failure handling, and invalidation. Documents and SPA fragments are isolated; credentialed/private responses bypass caching, and request hydration payloads replace build-time payloads. Added integration/privacy/lifecycle tests and docs/features/route-rules.md. Full local suite: 13,136 pass, 0 fail. CI green: https://github.com/stacksjs/stx/actions/runs/36007491605 . Scope: dynamic uses the existing compiled hydrator (structural loops/conditionals remain build-time); flat SSG, parameter-route prerendering, distributed/CDN invalidation and CDN-specific ISR are not added by this change. Unsupported policy combinations are rejected.

Sign in to comment on this issue.