feat: implement caching strategy for API responses and adjust loading timeout in CoverClient for improved performance

This commit is contained in:
Julien Froidefond
2025-10-17 23:20:42 +02:00
parent a22e77c4eb
commit ae4b766085
8 changed files with 58 additions and 20 deletions

View File

@@ -4,7 +4,7 @@ import { ERROR_CODES } from "@/constants/errorCodes";
import { AppError } from "@/utils/errors";
import { getErrorMessage } from "@/utils/errors";
import type { NextRequest } from "next/server";
export const dynamic = "force-dynamic";
export const revalidate = 60;
const DEFAULT_PAGE_SIZE = 20;
@@ -25,7 +25,14 @@ export async function GET(
SeriesService.getSeries(seriesId)
]);
return NextResponse.json({ books, series });
return NextResponse.json(
{ books, series },
{
headers: {
'Cache-Control': 'public, s-maxage=60, stale-while-revalidate=120'
}
}
);
} catch (error) {
console.error("API Series Books - Erreur:", error);
if (error instanceof AppError) {