diff --git a/app/page.js b/app/page.js index c9897d1..aa11a75 100644 --- a/app/page.js +++ b/app/page.js @@ -1,4 +1,5 @@ import {createDirectus, rest, readItems} from '@directus/sdk' +import {unstable_cache as nextCache} from 'next/cache' import Container from '@mui/material/Container' import Box from '@mui/material/Box' import Typography from '@mui/material/Typography' @@ -19,7 +20,7 @@ const navButton = { icon: } -async function getData() { +async function fetchConstitution() { if (!apiUrl) { throw new Error('DIRECTUS_API_URL is required') } @@ -58,6 +59,14 @@ async function getData() { } } +// Mise en cache des données constitution — revalidation toutes les 5 minutes. +// Le tag 'constitution' permet une invalidation à la demande via revalidateTag(). +const getData = nextCache( + fetchConstitution, + ['constitution-data'], + {revalidate: 300, tags: ['constitution']} +) + export default async function Page() { const session = await auth() const {titres, articles} = await getData() diff --git a/tasks/todo.md b/tasks/todo.md index b3c93bf..29de9b5 100644 --- a/tasks/todo.md +++ b/tasks/todo.md @@ -19,7 +19,7 @@ ## Améliorations moyennes (P3) -- [ ] ISR page d'accueil (`revalidate`) +- [x] ISR page d'accueil (`revalidate`) - [ ] Dockerisation frontend (`output: standalone`) - [ ] Audit accessibilité WCAG 2.1 - [ ] Responsive mobile dashboard