📋 Context & Problem Description
Currently, Gutter supports two primary loading strategies: Dynamic SSR (HTML is rendered dynamically on every HTTP request) and SSG (HTML pages pre-rendered at build time).
For pages with dynamic content that updates periodically but not in real-time (e.g. blog posts, product catalogs), dynamic SSR is CPU-heavy on the host Go server, while static SSG requires rebuilding/redeploying the entire site to reflect a change.
💡 Proposed Solution & Implementation Plan
Implement Incremental Static Regeneration (ISR) caching on the Gutter host server:
- Configurable Cache Lifetimes:
Allow defining a cache TTL on SSR routes:
gutter.SSRConfig{
Addr: ":8080",
Root: Root,
RevalidateSeconds: 60, // Keep static page for 60s
}
- Server-Side Page Cache:
- On request, check if a statically rendered HTML file for the request path exists in the memory/disk cache and check its age.
- If it is within the TTL, serve the static HTML directly (very low latency, high throughput).
- Stale-While-Revalidate Regeneration:
- If the cache is expired, immediately serve the stale static page (ensuring 0ms render latency for the current request).
- Spawn a background goroutine to execute
RenderToHTML on the widget tree, updating the cache with the new HTML for subsequent requests.
🎯 Impact & Benefits
- High Performance: Instant load times (similar to SSG) for the vast majority of requests.
- Low Server Overhead: Drastically reduces server rendering CPU usage under heavy traffic.
🏷️ Suggested Labels
feature, ssr, performance
📋 Context & Problem Description
Currently, Gutter supports two primary loading strategies: Dynamic SSR (HTML is rendered dynamically on every HTTP request) and SSG (HTML pages pre-rendered at build time).
For pages with dynamic content that updates periodically but not in real-time (e.g. blog posts, product catalogs), dynamic SSR is CPU-heavy on the host Go server, while static SSG requires rebuilding/redeploying the entire site to reflect a change.
💡 Proposed Solution & Implementation Plan
Implement Incremental Static Regeneration (ISR) caching on the Gutter host server:
Allow defining a cache TTL on SSR routes:
RenderToHTMLon the widget tree, updating the cache with the new HTML for subsequent requests.🎯 Impact & Benefits
🏷️ Suggested Labels
feature,ssr,performance