Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/gold-penguins-walk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@opennextjs/aws": minor
---

fix: allow bypassing the Tag Cache in the interceptor
10 changes: 5 additions & 5 deletions packages/open-next/src/core/routing/cacheInterceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,11 @@ export async function cacheInterceptor(
cachedData.value?.type === "route"
) {
const tags = getTagsFromValue(cachedData.value);
const _hasBeenRevalidated = await hasBeenRevalidated(
localizedPath,
tags,
cachedData,
);

const _hasBeenRevalidated = cachedData.shouldBypassTagCache
? false
: await hasBeenRevalidated(localizedPath, tags, cachedData);

if (_hasBeenRevalidated) {
return event;
}
Expand Down
17 changes: 17 additions & 0 deletions packages/tests-unit/tests/core/routing/cacheInterceptor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,23 @@ describe("cacheInterceptor", () => {
expect(result).toEqual(event);
});

it("should bypass the tag cache when shouldBypassTagCache is true", async () => {
const event = createEvent({
url: "/albums",
});
incrementalCache.get.mockResolvedValueOnce({
value: {
type: "app",
html: "Hello, world!",
},
shouldBypassTagCache: true,
});

await cacheInterceptor(event);

expect(tagCache.getLastModified).not.toHaveBeenCalled();
});

it("should take no action when tagCache lasModified is -1 for route type", async () => {
const event = createEvent({
url: "/albums",
Expand Down