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 to | Use | Guide |
|---|---|---|
| Render SSR data without refetching it, and skip repeat requests | App cache (TanStack Query) | Cache app data |
| Stop running the same slow database query for every visitor | API cache (Redis) | Cache API data |
Look up remember, delete, flush and the other methods | API cache (Redis) | Cache reference |
| Render a public page once and send that HTML to every visitor | Page cache | Cache 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.
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.