Skip to content

@ogygia/postrender

Debugging

Read the x-ogygia-postrender header to see how a response was answered, find the read that keeps a page per-request, and work out why a visitor still sees an old page. Every message postrender logs, with what to do.

On this page

Two questions come up once postrender runs. Why isn’t this page stored? And why does this page still show the old content? Both start from the response headers, and both are easier in a build than in dev, because dev never stores anything.

curl -s -o /dev/null -D - http://localhost:4173/pricing \
  | grep -i -e x-ogygia-postrender -e cache-control -e last-modified -e etag

Every response postrender answered carries x-ogygia-postrender. Its value says how:

ValueMeaning
storedThis request rendered the page, and the render was stored. The next request is a hit.
hitServed from the store. No load or component ran.
joinRendered by another request that came in at the same moment, and served from what it stored.
would-storeDev only: in a build, this render would be stored, unless the request carried a cookie. Router-table pages never get it in dev (below).
noneNot answered from the store: the request isn’t looked up, the render was refused, or it carried a cookie and no copy was stored yet.

A permanent redirect has no header on the request that stores it, and hit after that.

Next to it, last-modified is when the page was stored, and etag changes whenever the stored HTML does. cache-control says what postrender told caches: public, s-maxage=… for a stored page, private, no-store for one it refused.

The example below asks for a /welcome page whose load greets the visitor in their language with request.headers.get('accept-language'). Sent with that header, the render reads it and is refused. (Sent without it, the read comes back empty and the page is stored, as the canonical copy.)

curl -s -o /dev/null -D - -H 'accept-language: fr' http://localhost:4173/welcome \
  | grep -i -e x-ogygia-postrender -e cache-control
# cache-control: private, no-store
# (no x-ogygia-postrender: the render was refused)

Dev mode

In vite dev, nothing is stored and nothing is served from the store, so every edit shows at once. The verdict still runs on every eligible page:

  • A page that would be stored gets x-ogygia-postrender: would-store. Check it in the network panel. The dev check ignores the request’s cookies, and your browser almost always sends some to localhost, while a build never stores a render made for a request with a cookie. So read would-store as “the render is shareable”, and check from a request without cookies (curl, a private window), or set the route to 'with-credentials' (#2297, item 9).
  • A page that would be refused prints one line in the terminal, once per path, naming the read or the response that refused it (postrender_stays_per_request). For the welcome page it names /welcome and header:accept-language, since a browser always sends that header.
  • Pages from an @ogygia/router table are always reported as refused in dev, blaming “the app’s cache-control (no-store)“. The router stamps no-store on every page in dev, and the dev check reads that as your choice. A build stores those pages normally, so check them there (#2299).

To see real hits, build and run the app. vite preview runs the built server, with postrender storing as it will in production.

pnpm build && pnpm preview

Pages not stored

Work down this list:

  1. Is the request looked up at all? It has to be a GET with no query string, for a route that may be stored, from a browser without devtools switched on. See Which requests use the store.
  2. Did the request carry a cookie? Your browser usually does. A page that isn’t stored yet is never stored from such a request, so test with curl or a private window, or set 'with-credentials' on the route.
  3. What did the render read? Run it in dev and read the terminal note, which names the first personal read (cookie:currency, header:accept-language, locals.user, flag:hero, streamed load (promise in page data)) or the response that couldn’t be shared (status 404, a set-cookie response header, the app's cache-control (private)). What keeps a page per-request lists every one.
  4. Is the store working? A failing store makes every page render fresh, and logs postrender_store_failed.

The usual fix for a read is to move the personal part into a server island, so the rest of the page can be stored.

Stale pages

When a visitor still sees content you’ve changed, find where the old copy lives:

  1. The store. Request the page straight from your server, not through the CDN. x-ogygia-postrender: hit with an old last-modified means the store still holds it.
  2. The CDN. If your server sends the new page but the CDN doesn’t, the purge didn’t reach it. Look for postrender_fanout_failed in the logs, which names the edge. Some clears don’t reach some CDNs at all; Purge a CDN lists which. A CDN with no edge adapter is never purged; it keeps the page for its s-maxage.
  3. The browser. A stored page has a last-modified and no max-age (browsers ignore s-maxage), so a browser may treat it as fresh for a while by its own estimate, commonly a tenth of the time since last-modified, and show it without asking again, even after a clear. A page stored ten hours ago can stay in a browser for about an hour. A hard reload, or “Disable cache” in the browser’s devtools, rules this out.

If the store holds it, check the clear:

  • Did the path match the key? invalidate() takes the decoded pathname exactly, with the page’s trailing slash (Clear one page).
  • Did it reach every instance? With the memory store, a clear reaches only the instance that ran it. Use a shared store (Share pages across instances).
  • Did it run in the server? A clear from a separate script clears that script’s own empty memory store (Where to call it).
  • Did a source clear name the right arguments? invalidate(getDoc, ['promo']) matches only a render that called getDoc('promo') with the same arguments (Match the arguments). With a custom store, check it has evictByTag.
  • Did the write really happen? A write the store refused still shows x-ogygia-postrender: stored for now (#2297, item 10), so look for postrender_store_failed in the log.
  • Is the content itself old? A hit shows what the loads returned when the page was stored. If a data cache under them still had the old document then, the new render stored old content. Clear the data cache first, then the page.

To clear everything while you look, call postrender.invalidateWhere({ prefix: '/' }), and see Purge a CDN for what that clear reaches at your CDN.

Bypassing the store

To see a page as it renders now, without clearing it for everyone, add any query string: /pricing?fresh. A request with a query string is rendered, never answered from the store, and never stored. A browser with devtools switched on is the same: its pages are always rendered for it.

A cookie doesn’t bypass a stored page. Your signed-in browser is served the same copy as everyone else.

curl -s 'http://localhost:4173/pricing?fresh' -o /dev/null -D - | grep -i x-ogygia-postrender
# (nothing: rendered for this request)

Messages

Postrender’s own messages, each with a page that explains it:

CodeWhen
postrender_stays_per_requestDev: a page would be refused, and why.
postrender_handle_unlistedpostrender.handle() runs, but postrender() isn’t in the Vite config. Nothing is stored.
postrender_edges_without_shared_storeEdges are configured over the memory store.
postrender_store_failedA store call threw. Pages render fresh until it works again.
postrender_capture_failedStoring one page threw. It was sent as rendered.
postrender_fanout_failedThe store or one edge failed during a clear.
postrender_tag_evict_failedThe store failed to clear one data source’s pages.
postrender_store_no_evict_by_tagA custom store without evictByTag: on a clear by source, on the first request after each new build, and on a federation thaw notice.
postrender_invalidate_not_sourceThrown: invalidate(fn, args) got a function that isn’t a declared source.
postrender_adapter_request_failedA built-in store or edge got an error status from its service.
postrender_store_client_missingThe Valkey client has no set commands.
plugin_needs_pluginBuild: postrender() is listed without dataShake().
kit_config_not_literalBuild: a route’s config.postrender isn’t a literal.
macro_source_misuseBuild: import.meta.og.source() used somewhere other than a top-level export const.

Three setup mistakes print a plain message with the fix instead of a code: postrender.handle() placed after ogygia.handle() (an error on every page request in dev, one warning in production), no postrender.handle() at all (one warning; the memory store is used), and a config.postrender value that isn’t true, false or 'with-credentials'.