Skip to content

Commit

Permalink
Cache feed data for 15 minutes
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorsharp committed Apr 15, 2024
1 parent 212559f commit 9f2e4f7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/app/[feedId]/feed/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const GET = async (request: Request, { params }: { params: { feedId: string } })
const moddedFeedData = applyMods(feedData, modConfig);
const feed = buildFeed(moddedFeedData, feedId, host);

return new NextResponse(feed, { headers: { "Cache-Control": "s-maxage=600" } });
return new NextResponse(feed, { headers: { "Cache-Control": "s-maxage=900" } });
} catch (errorMessage) {
console.error(errorMessage);
return new NextResponse((errorMessage as string | undefined) ?? "Unexpected Error", {
Expand All @@ -27,4 +27,6 @@ const GET = async (request: Request, { params }: { params: { feedId: string } })
}
};

export const revalidate = 15 * 60;

export { GET };
1 change: 1 addition & 0 deletions src/services/feedService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const fetchFeedData = async (urls: string[], searchParams?: URLSearchParams) =>
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "OPTIONS,POST,GET",
},
next: { revalidate: 15 * 60 },
})
.then((response) => response.text())
.then((data) => parseFeed(data))
Expand Down

0 comments on commit 9f2e4f7

Please sign in to comment.