Logo VitNode

Cache

Cache

Choose where to cache in VitNode - TanStack Query in the app, Redis inside your Hono API routes, or the HTML of public server-rendered pages.

VitNode caches in three places. The app keeps API responses in TanStack Query, so a page never asks for something it already has. The API keeps expensive results in Redis through c.get("cache"), so a slow query runs once for everyone. The page cache stores the rendered HTML of public pages, so an article renders once for all its visitors. All three are opt-in: nothing is cached until your code asks for it.

Pick a layer

You want toUseGuide
Render SSR data without refetching it, and skip repeat requestsApp cache (TanStack Query)Cache app data
Stop running the same slow database query for every visitorAPI cache (Redis)Cache API data
Look up remember, delete, flush and the other methodsAPI cache (Redis)Cache reference
Render a public page once and send that HTML to every visitorPage cacheCache server-rendered pages

Most features use both. The API caches the expensive part once, and each visitor's app keeps its own copy of the response.

The fetcher never caches

fetcher() forwards the visitor's cookies, so a stored response could be one visitor's data served to another. That is why caching lives in the two layers above and not in the fetcher.

Content Engine public reads are not cached on the server. To cache them in your app or a separate front end, see Content Engine caching.

On this page