Performance, Threading, and Cache Lifecycles
Core Threading Rule
Framework components and modules are mutable objects.
Treat them as request-scoped unless you explicitly freeze output into cached HTML or stable templates.
Finish configuration before compiling or sharing structure; configuration is not thread-safe.
Standard Column rendering does not mutate its attributes and needs no warm-up before
concurrent template rendering. This is not a blanket sharing guarantee: retained custom
renderers (including framework overrides) and slot-provided components must be safe to share,
and each request should use its own RenderContext.
Safe Reuse Matrix
- Safe to reuse globally:
Templateinstances whose retained custom component delegates are safe to share- rendered HTML strings
- immutable config values
- Reuse with care:
RenderContextonly when lifecycle is explicit and synchronized by your app design
- Do not reuse across concurrent requests:
- mutable
ModuleorHtmlTaginstances being edited/mutated
- mutable
Preferred Performance Pattern
- Keep structure static in
Template. - Map request data into context.
- Render fragments, not whole pages, for HTMX updates.
Cache Lifecycles
Use clear invalidation triggers:
- content revision change
- tenant config change
- deployment/version rollover
Pseudo strategy:
startup: compile templates and warm static html where useful
request: fetch data -> context -> render
mutation: invalidate keys affected by changed domain objects
Avoidable Bottlenecks
- Rebuilding identical templates in request handlers.
- Re-rendering full shells when only one module changed.
- Sharing mutable module instances across request threads.
See rendering and lifecycle for the distinction between a render plan and cached output.