( Astro )
| 38 | } |
| 39 | |
| 40 | export 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 | |
| 56 | export async function catchRedirectResponse ( Astro ) { |
nothing calls this directly
no test coverage detected