File tree Expand file tree Collapse file tree 1 file changed +12
-10
lines changed
packages/cloudflare/src/api Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -66,16 +66,18 @@ class Cache implements IncrementalCache {
6666 lastModified : ( globalThis as { __BUILD_TIMESTAMP_MS__ ?: number } ) . __BUILD_TIMESTAMP_MS__ ,
6767 } ;
6868 }
69- // if we were unable to get the cached data from the KV we get it from the assets generated at build time
70- // however before serving them we need to make sure that they are not expired, otherwise if the KV cache
71- // is missing or not working properly we end up always serving the same stale build time generated cache entries
72- const entryValue = entry ?. value as CachedFetchValue ;
73- if ( entryValue ?. kind === "FETCH" ) {
74- const expires = entryValue . data . headers ?. expires ;
75- const expiresTime = new Date ( expires as string ) . getTime ( ) ;
76- if ( ! isNaN ( expiresTime ) && expiresTime <= Date . now ( ) ) {
77- this . debug ( `found expired entry (expire time: ${ expires } )` ) ;
78- return null ;
69+ if ( ! kv ) {
70+ // The cache can not be updated when there is no KV
71+ // As we don't want to keep serving stale data for ever,
72+ // we pretend the entry is not in cache
73+ const entryValue = entry ?. value as CachedFetchValue ;
74+ if ( entryValue ?. kind === "FETCH" ) {
75+ const expires = entryValue . data . headers ?. expires ;
76+ const expiresTime = new Date ( expires as string ) . getTime ( ) ;
77+ if ( ! isNaN ( expiresTime ) && expiresTime <= Date . now ( ) ) {
78+ this . debug ( `found expired entry (expire time: ${ expires } )` ) ;
79+ return null ;
80+ }
7981 }
8082 }
8183 }
You can’t perform that action at this time.
0 commit comments