T
TanStack4y ago
dependent-tan

Cache strategy for resources available on multiple endpoints?

Are there any best practices for handling resources that can fetch both as a batch and individually? Example: The https://swapi.dev/api/films endpoint returns six films. These films are also available individually by adding an ID to the URL. The React Query example (1) caches these two endpoints separately, resulting in everything being cached twice. Are there any examples / best practices on how to avoid this double cache? 1) https://codesandbox.io/s/github/tanstack/query/tree/main/examples/react/star-wars?from-embed=&file=/src/Film.jsx
CodeSandbox
@tanstack/query-example-react-star-wars - CodeSandbox
@tanstack/query-example-react-star-wars using @material-ui/core, @tanstack/react-query, @tanstack/react-query-devtools, react, react-dom, react-router, react-router-dom
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?