You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The swr option of the export const cache config on GET server actions (#488) is never explained on any doc surface. Every occurrence is the same inline code comment, { maxAge, swr, public }, with no prose saying what swr does, what unit it takes, or when to use it. A developer who wants proper Cache-Control on a GET action can learn maxAge and the public safety rule from the docs, but has to read framework source to learn swr.
Separately, the README feature list undersells cached GET actions: it says "cache() for queries, HTTP Cache-Control for pages" but never mentions that GET server actions carry Cache-Control + ETag, which is a headline differentiator versus Next.js (whose actions are POST-only).
Design / approach
Document what the implementation actually does. Source of truth is cacheControlFor() in packages/server/src/action-config.js (L143-149): on a GET action with a cache config, the response header is <private|public>, max-age=<maxAge>, and when swr > 0 it appends , stale-while-revalidate=<swr>. So swr is seconds, and it lets the browser serve the stale cached response instantly after maxAge expires while revalidating in the background (pairs with the weak ETag, so the revalidation is usually a 304).
Add one or two sentences of swr prose next to each existing export const cache example, and one clause to the README feature list. No behaviour change, docs only.
Implementation notes (for the implementing agent)
Where to edit (each already shows the { maxAge, swr, public } comment; add the swr explanation adjacent):
website/app/docs/server-actions/page.ts L170 (example) and the caching paragraph at L177.
website/app/docs/data-fetching/page.ts L77 (example) and the behaviour paragraph at L84.
AGENTS.md L308, the **HTTP-verb actions via config exports (#488)** paragraph: extend the export const cache = 60 parenthetical with a short swr clause. Keep it lean; the full prose belongs in the skill reference.
.agents/skills/webjs/references/data-and-actions.md L129 (example) and the GET bullet near L142.
README.md L26: extend "cache() for queries, HTTP Cache-Control for pages" to also name cached GET server actions (Cache-Control + ETag on action reads).
Landmines / gotchas:
The scaffold templates ship their own copy of the skill reference at packages/cli/templates/.agents/skills/webjs/references/data-and-actions.md. If it carries the same { maxAge, swr, public } line, update it in lockstep with the repo-root copy (grep both).
Prose invariant release: bump core/server/cli versions, honest engines fields #11 (AGENTS.md): no em-dashes, no space-surrounded hyphens or semicolons as pause punctuation, and WebJs capitalized in prose. The .claude/hooks/block-prose-punctuation.sh hook blocks violations in NEW content.
llms.txt / llms-full.txt are generated live from the doc pages; do not hand-edit them.
README.md L26 sits inside a sentence that continues onto the following lines (the setStore() clause); keep that sentence grammatical after the edit.
Invariants to respect: docs must describe cacheControlFor() truthfully (private default, swr appended only when > 0, GET only). Do not restate the public: true safety rule incorrectly; copy its existing framing.
Tests + docs surfaces: docs-only change, no test layer applies. Run webjs check for the touched doc pages under website/. All edited surfaces listed above ARE the doc-sync set for this change (verified via the webjs-doc-sync audit that produced this issue).
Acceptance criteria
Each surface above explains swr in prose: seconds, emits stale-while-revalidate=<n> in Cache-Control, serve-stale-then-revalidate semantics.
README names cached GET server actions in the feature list.
The scaffold template copy of the skill reference is in sync with the repo-root copy (or verified to not need it).
git grep -iE 'stale.while.revalidate' now hits prose (not just header examples) on the server-actions and data-fetching doc pages.
webjs check passes; prose-punctuation hook not violated.
Problem
The
swroption of theexport const cacheconfig on GET server actions (#488) is never explained on any doc surface. Every occurrence is the same inline code comment,{ maxAge, swr, public }, with no prose saying whatswrdoes, what unit it takes, or when to use it. A developer who wants properCache-Controlon a GET action can learnmaxAgeand thepublicsafety rule from the docs, but has to read framework source to learnswr.Separately, the README feature list undersells cached GET actions: it says "
cache()for queries, HTTP Cache-Control for pages" but never mentions that GET server actions carryCache-Control+ ETag, which is a headline differentiator versus Next.js (whose actions are POST-only).Design / approach
Document what the implementation actually does. Source of truth is
cacheControlFor()inpackages/server/src/action-config.js(L143-149): on a GET action with acacheconfig, the response header is<private|public>, max-age=<maxAge>, and whenswr > 0it appends, stale-while-revalidate=<swr>. Soswris seconds, and it lets the browser serve the stale cached response instantly aftermaxAgeexpires while revalidating in the background (pairs with the weak ETag, so the revalidation is usually a 304).Add one or two sentences of
swrprose next to each existingexport const cacheexample, and one clause to the README feature list. No behaviour change, docs only.Implementation notes (for the implementing agent)
Where to edit (each already shows the
{ maxAge, swr, public }comment; add theswrexplanation adjacent):website/app/docs/server-actions/page.tsL170 (example) and the caching paragraph at L177.website/app/docs/data-fetching/page.tsL77 (example) and the behaviour paragraph at L84.AGENTS.mdL308, the**HTTP-verb actions via config exports (#488)**paragraph: extend theexport const cache = 60parenthetical with a shortswrclause. Keep it lean; the full prose belongs in the skill reference..agents/skills/webjs/references/data-and-actions.mdL129 (example) and the GET bullet near L142.README.mdL26: extend "cache()for queries, HTTP Cache-Control for pages" to also name cached GET server actions (Cache-Control + ETag on action reads).Landmines / gotchas:
packages/cli/templates/.agents/skills/webjs/references/data-and-actions.md. If it carries the same{ maxAge, swr, public }line, update it in lockstep with the repo-root copy (grep both).WebJscapitalized in prose. The.claude/hooks/block-prose-punctuation.shhook blocks violations in NEW content.llms.txt/llms-full.txtare generated live from the doc pages; do not hand-edit them..tsfiles renderinghtmltemplates: no backticks insidehtmltemplate bodies (invariant feat(server): replace esbuild TS stripping with Node 24+ strip-types #9), and the pages are display-only so keep them free of client-side signals.README.mdL26 sits inside a sentence that continues onto the following lines (thesetStore()clause); keep that sentence grammatical after the edit.Invariants to respect: docs must describe
cacheControlFor()truthfully (private default,swrappended only when> 0, GET only). Do not restate thepublic: truesafety rule incorrectly; copy its existing framing.Tests + docs surfaces: docs-only change, no test layer applies. Run
webjs checkfor the touched doc pages underwebsite/. All edited surfaces listed above ARE the doc-sync set for this change (verified via the webjs-doc-sync audit that produced this issue).Acceptance criteria
swrin prose: seconds, emitsstale-while-revalidate=<n>inCache-Control, serve-stale-then-revalidate semantics.git grep -iE 'stale.while.revalidate'now hits prose (not just header examples) on the server-actions and data-fetching doc pages.webjs checkpasses; prose-punctuation hook not violated.