[RFC] Modern.js SSR Cache #4967
GiveMe-A-Name
started this conversation in
RFC Discussions
Replies: 1 comment 3 replies
-
This RFC is very clear, I still have a few questions about the cache store:
|
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
1. Background
Improve SSR render time and reduce CPU overload by using SSR cache.
Current Modern.js have a SPR Cache HOC, but it seems users don't like using it.
So we need improve it and optimize UX by using it.
2. Detailed Design
a. Rule Configuration
Use HOC
Current Modern.js has a PreRender HOC that receives cache strategy config.
interval
:Set the cache freshness retention period (unit: second). During this time, the cache will be used directly and without asynchronous rendering.staleLimit
: Set the time for the cache to fully expire (unit: second). During this time, the cache can be returned and a step rendering will be done, otherwise the result of re-rendering must be used.level
: Sets the level of computation rules for cache identifiers, usually used withincludes
andmatches
. The default value is 0.includes
: Sets the content to be included in the cache identity, used when the level is not 0. The default value is null.matches
: Set the value of query or header in the cache identification of the override rule, usually used in the cache classification, support for regular expressions. The default value is null.👍 Good: Caching policies can be easily configured depending on the route.
👎 Bad: This is invasive to the code
Use
modern.config.ts
👍 Good: This is't invasive to the code
👎 Bad: We need use RegExp to match the strategy.
✅ Using custom server (server/index.ts or server/cache.ts)
We appoints user should export a serverCache object.
Examples:
b. Cache Strategy
Cache Strategy would like stale-while-revalidate.
Cache in store
We would use globalStorage to store ssr cahe. More detail see: #4968
c. Apply Range
Beta Was this translation helpful? Give feedback.
All reactions