Replies: 3 comments 10 replies
-
It doesn't have any cache built-in, but you can either setup a server-side cache or an HTTP cache.
No, it doesn't, if you want to cache server-side request to another API you need to do it yourself, some ways could include using an in-memory LRU cache if you have a long running server, or something like Redis on serverless of if you want to ensure it's cached even after a restart of the server.
They kind of have one, the browser can cache request if using HTTP cache, but also they keep the data of every loader in a state in memory, if you navigate client-side to another child route any parent route will not be refetched again and instead it will use the already fetched value, so you could say this is a cache, but if an action happens Remix will revalidate all loaders data and use fetch it again. Also if you were on |
Beta Was this translation helpful? Give feedback.
-
The headers documentation has some good points on setting up http cache headers for client side caching: https://remix.run/docs/en/v1/api/conventions#headers You can also add cache control headers to data routes using |
Beta Was this translation helpful? Give feedback.
-
quick question on HTTP caching: Is adding this the solution to solve the issue on mobile where you hit the back button and see either an empty page or the page flash old content -> new content? When I hit back on mobile browsers, the loader gets re-run and then either shows a blank page or incorrect content before flashing the correct content, and I was never sure how to solve this issue. |
Beta Was this translation helpful? Give feedback.
-
I'm bit confused about caching and documentation. The Jokes App tutorial says:
Does Remix have some default caching on the server side (browser-server communication path)?
Does Remix have some default caching on the server side for the backend APIs?
Does Remix have some default caching on the client side?
I assume there is no default cashing, but he Jokes App tutorial (which is official docs) suggests otherwise.
I imagine someone might think some default caching based on route conventions could be neat, like
/article/123/edit
action invalidating/article/123
, but it raises obvious questions about invalidation of other routes based on the mutated data (say/top-10-articles
) and other issues.I think the documentation could be clearer about caching and maybe even suggest best practices - like HAProxy, Redis for API caching, considerations for edge app deployment, client-side service worker caching (PWA) using Workbox etc.
Beta Was this translation helpful? Give feedback.
All reactions