Skip to content

Public sites performance: caching strategy and page weight #75

Open
1 of 3 issues completed
Open

Description

@clbotdev

Make FrontLit public sites (apps/sites) fast by default and in line with industry standards for hosted docs and marketing portals. Everything must work when self-hosted: the cache lives inside FrontLit, and a CDN is an optional extra in front of it, never required for correct delivery.

Today

  • Every request renders on demand. The tenant layout reads request headers (x-frontlit-embed, x-frontlit-canonical-host), so Next can't cache whole pages. The only caching is a 60-second, per-pod data cache.
  • Docs are never cached. They use no-store end to end, so every docs view hits the API and database.
  • revalidateTag only reaches one replica. The webhook clears the cache on the pod that receives it; the data and host caches are per pod.
  • The whole page is a client component. The page-builder renderer is shipped to and run in the browser.
  • Images are served at full size. Raw <img>, MediaLit originals, no resizing.

Decisions

  • MediaLit serves public media through its CDN when configured. It is not the edge cache/CDN for FrontLit site responses (HTML and RSC); Layer 2 caches those responses and uses FrontLit’s invalidation flow. MediaLit remains the media storage and delivery layer.
  • Every caching layer must be self-hosting friendly and vendor-neutral.
  • Docs drop the "zero staleness / no-store" rule (docs-management.md §23.3). They are cached and invalidated on publish via the signed outbox webhook; staleness is bounded by webhook delivery, normally under a second. Search, chat and the public docs API stay authoritative and uncached.

Phases

Targets

  • Cache hit ratio above 95%.
  • TTFB p75 under 100ms on cache hits.
  • LCP under 1.5s, CLS under 0.1, INP under 200ms.

Activity

  1. clbotdev commented on Oct 25, 2026

    @clbotdev
    ContributorAuthor

    Status and measured results. Same sample tenant throughout: 9-block homepage with 8 images, 12 docs, 7 posts. Local machine; Lighthouse mobile, median of 5.

    PR Phase Result
    #142 1 follow-up (#71) Article and feed images now optimized: blog post images 172 KB → 44 KB
    #143 2 (#72) Repeat views make 0 API calls. Publish → visible in 0.18–0.35 s (docs 0.43–0.54 s). Throughput 41 → 140 req/s (home). Second replica via Redis: 0.33–0.48 s
    #144 3 (#73) Varnish recipe: 4.9k–7.4k req/s at p50 1 ms. Edge purge → visible in 0.2–0.5 s. ttl mode capped at the TTL. Fixed an RSC cache-poisoning case behind Vary-ignoring CDNs
    #145 4 (#74), partly Cloudflare purge adapter, Web Vitals RUM in Prometheus, Grafana dashboard. Vendor and TLS decisions pending (see #74)

    Phase 1 (#78) against the commit before it:

    • Performance score: 55 → 91 (home), 73 → 93 (docs), 69 → 90 (blog).
    • TBT: 1.1–1.3 s → 0.14–0.23 s.
    • JavaScript: 643 KB → 192 KB.

    Against the targets:

    • Met: TTFB on cache hits is 7–17 ms (Lighthouse) and about 1 ms at the edge. CLS is 0.
    • Not met in simulation: LCP is 2.5–3.6 s under Lighthouse's simulated slow 4G. It's dominated by the hero image and render-blocking CSS rather than the server. Field p75 will come from the new RUM dashboard.
    • To watch: TBT rose to 0.2–0.38 s with Cache Components. Total main-thread work is unchanged; hydration just runs in longer tasks.

    PRs #143 → #144 → #145 are stacked; #142 is independent.

  2. clbotdev commented on Oct 25, 2026

    @clbotdev
    ContributorAuthor

    #142–#145 are merged; Phases 1–3 are done. Phase 4 (#74) is waiting on the vendor and custom-domain TLS decisions (recommendation in docs/site-delivery.md §7a). The Cloudflare adapter and RUM are already on main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions