From 09c7ce00091dde7354577e1cb02a3b2eba5b2c6d Mon Sep 17 00:00:00 2001 From: Mike Decker Date: Tue, 23 Jan 2024 15:39:08 -0800 Subject: [PATCH] Reduce revalidation logic --- app/api/revalidate/route.tsx | 3 --- src/lib/drupal/get-paths.tsx | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/api/revalidate/route.tsx b/app/api/revalidate/route.tsx index cce06b73..ed8e817c 100644 --- a/app/api/revalidate/route.tsx +++ b/app/api/revalidate/route.tsx @@ -1,6 +1,5 @@ import {NextRequest, NextResponse} from "next/server"; import {revalidatePath, revalidateTag} from "next/cache"; -import {getAllDrupalPaths} from "@lib/drupal/get-paths"; export const revalidate = 0; @@ -24,8 +23,6 @@ export const GET = async (request: NextRequest) => { } tagsInvalidated.map(tag => revalidateTag(tag)); - await getAllDrupalPaths(true); revalidatePath(path); - console.log('invalidated path', path); return NextResponse.json({revalidated: true, path, tags: tagsInvalidated}); } \ No newline at end of file diff --git a/src/lib/drupal/get-paths.tsx b/src/lib/drupal/get-paths.tsx index 8732da2b..34f0b8da 100644 --- a/src/lib/drupal/get-paths.tsx +++ b/src/lib/drupal/get-paths.tsx @@ -28,11 +28,13 @@ export const getAllDrupalPaths = cache(async (cacheBust?: boolean): Promise => { const params = new DrupalJsonApiParams(); const pageLimit = 500; + // Add a simple include so that it doesn't fetch all the data right now. The full node data comes later, we only need // the node paths. params.addInclude(['node_type']); params.addPageLimit(pageLimit); + // Append a parameter to bypass any cache between here and the Drupal backend. if (cacheBust) params.addCustomParam({'cache1': new Date().getTime()}) const contentTypes = [ @@ -69,6 +71,7 @@ const getRedirectPaths = async (cacheBust?: boolean): Promise => { const params = new DrupalJsonApiParams(); const pageLimit = 500; params.addPageLimit(pageLimit); + if (cacheBust) params.addCustomParam({'cache1': new Date().getTime()}) let redirects: DrupalRedirect[] = []