MCPcopy Create free account
hub / github.com/ThatGuySam/doesitarm / applyResponseDefaults

Function applyResponseDefaults

helpers/astro/request.js:40–53  ·  view source on GitHub ↗
( Astro )

Source from the content-addressed store, hash-verified

38}
39
40export async function applyResponseDefaults ( Astro ) {
41 const maxAgeSeconds = getMaxAgeForUrl( Astro )
42
43 // 'stale-while-revalidate' tells Cloudflare to cache the response for X seconds
44 // but update the cache in the background
45 // so the user always gets a fast and cached response.
46 //
47 // This also means our Astro SSR entry function on Netlify
48 // only gets called from Cloudflare instead of the user's browser
49 // so that our actual number of requests to Netlify are minimized.
50 //
51 // Cache-Control: s-maxage=1, stale-while-revalidate
52 Astro.response.headers.set( 'Cache-Control', `s-maxage=${ maxAgeSeconds }, stale-while-revalidate` )
53}
54
55
56export async function catchRedirectResponse ( Astro ) {

Callers

nothing calls this directly

Calls 2

getMaxAgeForUrlFunction · 0.85
setMethod · 0.80

Tested by

no test coverage detected