This repository was archived by the owner on Apr 20, 2023. It is now read-only.
Open
Conversation
cbc6a8a to
a22d3a8
Compare
Owner
|
Please create your own fork to add any new functionality, I'm not interested in making more changes here. |
a22d3a8 to
1b2434e
Compare
stale-while-revalidate allows resources that are accessed often to be refreshed asynchronously. This is implemented by a new freshness state that returns the cached response, but triggers an asynchronous request that gets stored in the cache. ## Example If we need to call an external service to generate short-lived user JWT tokens (e.g., valid for a minute) Imagine this request is slow and needs to be cached so the app is more responsive. However I we don't want the app to hang every minute when the JWT token expires, so it needs to be refreshed asynchronously. Instead of returning `cache-control: max-age=60`, it can now return `cache-control: max-age=30, stale-while-revalidate=30`, so that JWT tokens for users making frequent requests are regenerated every ~30s. (If the user stays away for over a minute the next request will be slower)
1b2434e to
6bbd60b
Compare
6bbd60b to
48d350d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
stale-while-revalidate allows resources that are accessed often to be refreshed asynchronously.
This is implemented by a new freshness state that returns the cached response, but triggers an asynchronous request that gets stored in the cache.
Example
If we need to call an external service to generate short-lived user JWT tokens (e.g., valid for a minute)
Imagine this request is slow and needs to be cached so the app is more responsive. However we don't want the app to hang every minute when the JWT token expires, so it needs to be refreshed asynchronously.
Instead of returning
cache-control: max-age=60, it can now returncache-control: max-age=30, stale-while-revalidate=30, so that JWT tokens for users making frequent requests are regenerated every ~30s.(If the user stays away for over a minute the next request will be slow)