mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-18 06:44:46 -07:00
Comment on context of cache-control
This commit is contained in:
parent
53feb3c100
commit
6c7cbf5782
1 changed files with 8 additions and 0 deletions
|
|
@ -38,6 +38,14 @@ function getMaxAgeForUrl ( Astro ) {
|
|||
export async function applyResponseDefaults ( Astro ) {
|
||||
const maxAgeSeconds = getMaxAgeForUrl( Astro )
|
||||
|
||||
// 'stale-while-revalidate' tells Cloudflare to cache the response for X seconds
|
||||
// but update the cache in the background
|
||||
// so the user always gets a fast and cached response.
|
||||
//
|
||||
// This also means our Astro SSR entry function on Netlify
|
||||
// only gets called from Cloudflare instead of the user's browser
|
||||
// so that our actual number of requests to Netlify are minimized.
|
||||
//
|
||||
// Cache-Control: s-maxage=1, stale-while-revalidate
|
||||
Astro.response.headers.set( 'Cache-Control', `s-maxage=${ maxAgeSeconds }, stale-while-revalidate` )
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue