Skip to main content
Version: v10.5.0

Cache

The Cache page lists every entry in your client's cache with its freshness and the number of components that read it. Open an entry to see its data and timers, and change it while the app runs: edit a value, mark it stale, remove it or replace it with an error. Your hooks pick up each change at once, which makes the page a quick way to test empty, stale and error states without touching the server.

Each row is one cache key with its freshness, observers and last update.


Read the list​

ColumnMeaning
Cache KeyThe key the response is stored under, built from the method, endpoint, params and query params
StatusFresh until staleTime passes, then Stale, with a live countdown
ObserversHow many subscriptions in your app read this entry
Last updatedWhen the entry last changed

Use Search by cache key to find an entry. Two entries that you expected to be one usually differ in a param or a query param, and the key shows the difference.

What counts as an observer

Every mounted useFetch, useSubmit and useCache that reads the key counts as one observer, and so does every cache.events.onDataByKey listener in your code. An entry with no observers is data no component shows right now.


Inspect an entry​

Select a row to open the entry.

An entry with its countdowns and data. The values are editable.

The overview shows the observers, the last update and two countdowns:

  • Time left before stale counts down staleTime. After it, the next useFetch that mounts with this key refetches.
  • Time left for garbage collection counts down cacheTime. When it ends, the entry is removed from the cache.

A Hydrated badge marks entries that came from server rendering through <Hydrate>.

The Cache tab holds the response: data, error, status, success, extra and the timestamps. The Details tab holds the rest of the entry, such as staleTime and cacheTime.


Change an entry​

Changes apply to the cache in your app right away, and every hook that reads the entry re-renders with them.

The actions menu of a cache entry.

ActionWhat happens in your app
Edit a valueThe entry is saved with the new value. Text, numbers, booleans and dates are editable inline.
Invalidate CacheThe entry becomes stale, and mounted hooks that read it refetch
Remove Cache EntryThe entry is deleted, and mounted useFetch hooks that read it fetch it again
Simulate ErrorThe entry is replaced with a failed response, so hooks render their error state

Simulate Error asks which error to use. The list comes from Simulated Errors in the app's settings, where you can add errors with your own status code and body. The simulated error stays until the next successful request replaces it.

Test your empty and error states

Simulate an error to see your error UI, edit a name to check long text, or invalidate an entry to watch every component that reads it refetch. A refetch in your app brings the real data back.

Read Cache for how keys, staleTime and cacheTime work in the client.


Next steps​