server-components-demo icon indicating copy to clipboard operation
server-components-demo copied to clipboard

Suggestion: Stale While Revalidate cache management

Open arnaudbzn opened this issue 4 years ago • 1 comments

The demo is great and the performances are impressive.

More and more, Web apps use State While Revalidate for remote data fetching thanks to excellent libraries as SWR, react-query and Apollo Client.

It makes sense for React Server Components to support this pattern too.

In the demo, the data stored in the Postgres database could be changed by another user. In the current implementation, only mutations done by the current app user refresh the cache. With State While Revalidate remote data fetching, the changes done by other users will be reflected.

It would be great to see this feature demonstrated with React Server Components even in a minimal version.

arnaudbzn avatar Dec 27 '20 15:12 arnaudbzn

In this demo you could do this by invalidating the cache more often (see useRefresh). We’ll offer more granular refetching and cache invalidation APIs in the future versions.

gaearon avatar Jan 02 '21 03:01 gaearon