Skip to content

fix: allow caching for _serverFn requests - #69

Merged
JonasJesus42 merged 1 commit into
mainfrom
fix/serverfn-cache-bypass
Apr 7, 2026
Merged

JonasJesus42 merged 1 commit into
mainfrom
fix/serverfn-cache-bypass

Conversation

@JonasJesus42

@JonasJesus42 JonasJesus42 commented Apr 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • /_serverFn/ URLs (CMS section server functions for shelves, deferred sections) were incorrectly matched by the /_server prefix in both detectCacheProfile and DEFAULT_BYPASS_PATHS, forcing Cache-Control: private, no-cache, no-store, must-revalidate
  • Narrowed the match to /_server/ (trailing slash) so only TanStack Router internal RPC is bypassed, while /_serverFn/ falls through to the default "listing" profile with proper public caching (edge 120s, browser 30s + SWR/SIE)

Test plan

  • Deploy a storefront with this change and verify _serverFn shelf requests return public Cache-Control headers instead of private, no-cache, no-store, must-revalidate
  • Verify /_server/ RPC calls (TanStack Router internal) still bypass cache correctly
  • Check shelf load times improve with CDN/browser caching enabled

🤖 Generated with Claude Code


Summary by cubic

Allows public caching for /_server and /_serverFn requests, while protecting private responses with a Set-Cookie guard. This speeds up shelves and deferred sections via CDN/browser caching.

  • Bug Fixes
    • Removed /_server from the "no cache" detector and DEFAULT_BYPASS_PATHS; defaults now only include /_build, /deco/, /live/, /.decofile.
    • /_server and /_serverFn now use the standard public caching profile.
    • Added a safeguard: any response with Set-Cookie is forced to private and bypassed to prevent token leakage.

Written for commit 38b528f. Summary will update on new commits.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

@JonasJesus42
JonasJesus42 force-pushed the fix/serverfn-cache-bypass branch from 6172e93 to 8596fef Compare April 7, 2026 22:58
Remove /_server from DEFAULT_BYPASS_PATHS and detectCacheProfile "none"
pattern. Server function responses (/_server/, /_serverFn/) carry public
CMS data (shelves, sections, product lists) that should be cacheable.

Private responses are still protected: any response with Set-Cookie is
forced to "private, no-cache, no-store" in both the cacheable and
non-cacheable flows, preventing session/cart tokens from leaking to
other users through cached responses.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@JonasJesus42
JonasJesus42 force-pushed the fix/serverfn-cache-bypass branch from 8596fef to 38b528f Compare April 7, 2026 23:02
@JonasJesus42
JonasJesus42 merged commit 277b4ad into main Apr 7, 2026
@github-actions

github-actions Bot commented Apr 7, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 1.2.10 🎉

The release is available on:

Your semantic-release bot 📦🚀

vitoUwu pushed a commit to vitoUwu/deco-start that referenced this pull request Jul 21, 2026
…n-migration skill

New skill .agents/skills/decocms-v6-to-v7-upgrade/ teaches upgrading a
TanStack site from @decocms/[email protected] + @decocms/[email protected] to the split
7.x packages. Distilled from three production migrations: lebiscuit
(73daa3b → b5fdf69 → 6d311d8, the canonical commit sequence), miess
PR decocms#86, granadobr PR decocms#69. Covers the dep swap (only the apps-* splits a
site imports), the complete mechanical old→new import mapping
(references/import-mapping.md — setup split into
createSiteSetup/createAdminSetup, hooks barrel split, routes/router/
workerEntry to the @decocms/tanstack root), the .deco/ artifact move
(invoke.gen.ts stays in src/ — empirically load-bearing), every edge
case we hit (useHydrated from @tanstack/react-router, cookiePassthrough
public at 7.6+ and the client-bundle-leak trap of the older shims,
deferredSectionLoader public at 7.7+, the pre-7.7 --apps-dir and
neverDefer workarounds fixed earlier in this branch, granadobr's
site-globals generator, double-encoded block filenames self-healing via
generate-blocks' parseBlockId-matching single decode), and the six
verification gates (clean lockfile, idempotent regeneration, typecheck
diff-vs-baseline, build, dev smoke, preview parity diff).

.claude/skills/run-migration/SKILL.md rewritten: it described the
Fresh→TanStack flow with hardcoded /Users/jonasjesus/... paths and the
long-gone repo-root scripts/migrate.ts. It now points at the migrator's
real home (packages/blocks-cli/scripts/migrate/, run via tsx from a
checkout of this repo or the published deco-migrate bin), stays generic
about paths, and cross-links the new v6→v7 skill for already-TanStack
sites. The migrator's DETECT patterns that match legacy @decocms/start
code in sites are intentionally untouched — they detect old code on
purpose, and the skill now says so.

Co-Authored-By: Claude Fable 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant