Skip to content

[Feature] Support Incremental Static Regeneration (ISR) Cache #13

@HaHiepThanh

Description

@HaHiepThanh

📋 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:

  1. Configurable Cache Lifetimes:
    Allow defining a cache TTL on SSR routes:
    gutter.SSRConfig{
        Addr: ":8080",
        Root: Root,
        RevalidateSeconds: 60, // Keep static page for 60s
    }
  2. 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).
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions