diff --git a/packages/runtime/src/templates/getHandler.ts b/packages/runtime/src/templates/getHandler.ts index 6ecbd1c2b2..37642e50bc 100644 --- a/packages/runtime/src/templates/getHandler.ts +++ b/packages/runtime/src/templates/getHandler.ts @@ -131,8 +131,9 @@ const makeHandler = (conf: NextConfig, app, pageRoot, staticManifest: Array<[str // ODBs currently have a minimum TTL of 60 seconds result.ttl = Math.max(ttl, 60) } - // Only cache 404s ephemerally - if (ttl === ONE_YEAR_IN_SECONDS && result.statusCode === 404) { + const ephemeralCodes = [301, 302, 307, 308, 404] + if (ttl === ONE_YEAR_IN_SECONDS && ephemeralCodes.includes(result.statusCode)) { + // Only cache for 60s if default TTL provided result.ttl = 60 } if (result.ttl > 0) {