diff --git a/app/api/revalidate/route.tsx b/app/api/revalidate/route.tsx index cce06b73..14b06cb1 100644 --- a/app/api/revalidate/route.tsx +++ b/app/api/revalidate/route.tsx @@ -24,8 +24,9 @@ export const GET = async (request: NextRequest) => { } tagsInvalidated.map(tag => revalidateTag(tag)); + // Fetch all the drupal paths with a cache busting string 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[] = []