Skip to content

Commit 0fd916d

Browse files
committed
fix: set cache tags on 404 pages
1 parent 2b0280b commit 0fd916d

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/run/handlers/cache.cts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,6 @@ export class NetlifyCacheHandler implements CacheHandlerForMultipleVersions {
123123
private captureCacheTags(cacheValue: NetlifyIncrementalCacheValue | null, key: string) {
124124
const requestContext = getRequestContext()
125125

126-
if (!cacheValue) {
127-
return
128-
}
129-
130126
// Bail if we can't get request context
131127
if (!requestContext) {
132128
return
@@ -142,6 +138,13 @@ export class NetlifyCacheHandler implements CacheHandlerForMultipleVersions {
142138
return
143139
}
144140

141+
// Set cache tags for 404 pages as well so that the content can later be purged
142+
if (!cacheValue) {
143+
const cacheTags = [`_N_T_${key === '/index' ? '/' : encodeURI(key)}`]
144+
requestContext.responseCacheTags = cacheTags
145+
return
146+
}
147+
145148
if (
146149
cacheValue.kind === 'PAGE' ||
147150
cacheValue.kind === 'PAGES' ||

0 commit comments

Comments
 (0)