Skip to content

Commit

Permalink
Merge pull request #68 from Floorp-Projects/fix-fetch-cache
Browse files Browse the repository at this point in the history
Set the revalidate option in the fetch API to explicitly define the cache expiration time.
  • Loading branch information
typeling1578 authored Nov 25, 2024
2 parents 64bc695 + 0596e9a commit 7abbbde
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/[lang]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ const getHeroProps = async (lang: Locale) => {
}

const getFirstTwoArticles = async (top: number = 2) => {
const res = await fetch('https://wpapi.ablaze.one/?home=https://blog.ablaze.one/&categories=45');
const res = await fetch(
'https://wpapi.ablaze.one/?home=https://blog.ablaze.one/&categories=45',
{ next: { revalidate: 3600 } }
);
const articles = (await res.json()).items;
let result: ArticleResponse[] = [];
for (let i = 0; i < Math.min(articles.length, top); i++) {
Expand Down

0 comments on commit 7abbbde

Please sign in to comment.