You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: port stale-while-revalidate tag revalidation from AWS
Ports opennextjs-aws #1122 and #1142 on top of the cache handler function.
- Tags carry optional `stale` and `expire` durations: `writeTags` accepts a
`{ tag, stale, expire }` input as well as a plain name, `OriginalTagCache`
entries gained the same fields, and both tag cache flavours gained an optional
`isStale`.
- `Cache.revalidateTags` takes the durations; the cache handler function turns
the `expire` delay into a timestamp, callers pass it through unchanged.
- The composable cache handler implements `updateTags`, added in Next.js 16.
- New per-request `RequestCache` on the OpenNext request context, so overrides
can deduplicate work within a request without touching global state, and
`globalThis.nextVersion` is injected in the esbuild banner.
- DynamoDB, fs-dev and the Cloudflare D1 / KV / sharded DO tag caches are
updated for the new signatures.
// We can reuse the same query as getLastModified since it already checks for revalidatedAt > lastModified as revalidatedAt and stale have the same value
231
+
constresult=awaitawsFetch(
232
+
JSON.stringify({
233
+
TableName: CACHE_DYNAMO_TABLE,
234
+
IndexName: "revalidate",
235
+
KeyConditionExpression: "#key = :key AND #revalidatedAt > :lastModified",
236
+
ExpressionAttributeNames: {
237
+
"#key": "path",
238
+
"#revalidatedAt": "revalidatedAt",
239
+
},
240
+
ExpressionAttributeValues: {
241
+
":key": {S: buildDynamoKey(key)},
242
+
":lastModified": {N: String(lastModified??0)},
243
+
},
244
+
})
245
+
);
246
+
if(result.status!==200){
247
+
thrownewRecoverableError(`Failed to check stale tags: ${result.status}`);
0 commit comments