Skip to content

Commit

Permalink
Reduce revalidation logic
Browse files Browse the repository at this point in the history
  • Loading branch information
pookmish committed Jan 23, 2024
1 parent a2b1138 commit 09c7ce0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 0 additions & 3 deletions app/api/revalidate/route.tsx
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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});
}
3 changes: 3 additions & 0 deletions src/lib/drupal/get-paths.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ export const getAllDrupalPaths = cache(async (cacheBust?: boolean): Promise<Map<
const getNodePaths = async (cacheBust?: boolean): Promise<string[]> => {
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 = [
Expand Down Expand Up @@ -69,6 +71,7 @@ const getRedirectPaths = async (cacheBust?: boolean): Promise<string[]> => {
const params = new DrupalJsonApiParams();
const pageLimit = 500;
params.addPageLimit(pageLimit);

if (cacheBust) params.addCustomParam({'cache1': new Date().getTime()})

let redirects: DrupalRedirect[] = []
Expand Down

0 comments on commit 09c7ce0

Please sign in to comment.