This repository has been archived by the owner on Jul 26, 2023. It is now read-only.
🚀 Edge caching #407
spencerwooo
announced in
Announcements
Replies: 2 comments 3 replies
-
👀 好耶!缓存终于来了。 |
Beta Was this translation helpful? Give feedback.
1 reply
-
我发现个小问题,如果 所以 |柱|ω・`) 我觉得也许还能再优化一下? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
🚀 Performance improvements with edge caching
Folder listing, thumbnail, search, etc., are now cached with Vercel's edge function caching. You should experience extremely faster load speed for these routes, especially folder listings. (Note: the thumbnails themselves are not cached to follow Vercel's fair use policy, only the URL pointing to the thumbnails are cached.)
The cache is valid for 60 seconds on the edge. - This means you won't see your newly added files for at least 60 seconds after your files are done uploading.
If you want to manually purge the cache of your site, you can do so by triggering a redeployment manually.
🛠 Technical details
Relevant headers:
You can check for response headers
x-vercel-cache
to see whether your request is responsed by a cache hit (fast 🐰), or fresh revalidated data (slow 🐢).Cache miss
Most often, no cache is present at the edge when someone first visits a route. This is presented as cache miss, where the response header
x-vercel-cache
is set toMISS
. In this scenario, fresh data is requested from the upstream API, and you will experience a slow load speed (compared to other scenarios).Cache hit
After the route is requested, Vercel will cache the function response at the edge. When a second request on the same route is triggered, Vercel will respond with the cache instead of requesting data from the upstream for a second time. This is presented as cache hit, where the response header
x-vercel-cache
is set toHIT
. You will experience an instant response.Cache stale
If the cache is present for longer than 60 seconds, on the request triggered, Vercel will respond with the stale cache, setting
x-vercel-cache
toSTALE
, and perform a new request to the upstream API. In this case, the following response is guaranteed to be fresh, and Vercel will update the cache on the edge accordingly. You will experience an instant response for both requests.Beta Was this translation helpful? Give feedback.
All reactions