Skip to content

Commit 23d8d3b

Browse files
authored
feat: cache redirects for 60 seconds if no ttl provided (#1677)
1 parent c4427a9 commit 23d8d3b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

packages/runtime/src/templates/getHandler.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,9 @@ const makeHandler = (conf: NextConfig, app, pageRoot, staticManifest: Array<[str
131131
// ODBs currently have a minimum TTL of 60 seconds
132132
result.ttl = Math.max(ttl, 60)
133133
}
134-
// Only cache 404s ephemerally
135-
if (ttl === ONE_YEAR_IN_SECONDS && result.statusCode === 404) {
134+
const ephemeralCodes = [301, 302, 307, 308, 404]
135+
if (ttl === ONE_YEAR_IN_SECONDS && ephemeralCodes.includes(result.statusCode)) {
136+
// Only cache for 60s if default TTL provided
136137
result.ttl = 60
137138
}
138139
if (result.ttl > 0) {

0 commit comments

Comments
 (0)