refactor: remove HTTP Cache-Control headers and revalidate settings from API routes to streamline caching strategy and avoid conflicts with server-side caching
This commit is contained in:
@@ -83,12 +83,13 @@ size: "1000"; // Récupère TOUS les livres d'un coup
|
|||||||
- Garder uniquement le cache SW pour : images, static, navigation
|
- Garder uniquement le cache SW pour : images, static, navigation
|
||||||
- Le cache serveur suffit pour les données
|
- Le cache serveur suffit pour les données
|
||||||
|
|
||||||
- [ ] **2.2 Supprimer les headers HTTP Cache-Control**
|
- [x] **2.2 Supprimer les headers HTTP Cache-Control**
|
||||||
|
|
||||||
- Retirer `Cache-Control` des NextResponse dans les routes API
|
- Retirer `Cache-Control` des NextResponse dans les routes API
|
||||||
- Évite les conflits avec le cache serveur
|
- Évite les conflits avec le cache serveur
|
||||||
|
- Note: Conservé pour les images de pages de livres (max-age=31536000)
|
||||||
|
|
||||||
- [ ] **2.3 Supprimer `revalidate` des routes dynamiques**
|
- [x] **2.3 Supprimer `revalidate` des routes dynamiques**
|
||||||
|
|
||||||
- Routes API = dynamiques, pas besoin d'ISR
|
- Routes API = dynamiques, pas besoin d'ISR
|
||||||
- Le cache serveur suffit
|
- Le cache serveur suffit
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import { ERROR_CODES } from "@/constants/errorCodes";
|
|||||||
import { AppError } from "@/utils/errors";
|
import { AppError } from "@/utils/errors";
|
||||||
import { getErrorMessage } from "@/utils/errors";
|
import { getErrorMessage } from "@/utils/errors";
|
||||||
import logger from "@/lib/logger";
|
import logger from "@/lib/logger";
|
||||||
export const revalidate = 60;
|
|
||||||
|
|
||||||
export async function GET() {
|
export async function GET() {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import { AppError } from "@/utils/errors";
|
|||||||
import { getErrorMessage } from "@/utils/errors";
|
import { getErrorMessage } from "@/utils/errors";
|
||||||
import type { NextRequest } from "next/server";
|
import type { NextRequest } from "next/server";
|
||||||
import logger from "@/lib/logger";
|
import logger from "@/lib/logger";
|
||||||
export const revalidate = 60;
|
|
||||||
|
|
||||||
const DEFAULT_PAGE_SIZE = 20;
|
const DEFAULT_PAGE_SIZE = 20;
|
||||||
|
|
||||||
@@ -27,14 +26,7 @@ export async function GET(
|
|||||||
LibraryService.getLibrary(libraryId),
|
LibraryService.getLibrary(libraryId),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return NextResponse.json(
|
return NextResponse.json({ series, library });
|
||||||
{ series, library },
|
|
||||||
{
|
|
||||||
headers: {
|
|
||||||
"Cache-Control": "public, s-maxage=60, stale-while-revalidate=120",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error({ err: error }, "API Library Series - Erreur:");
|
logger.error({ err: error }, "API Library Series - Erreur:");
|
||||||
if (error instanceof AppError) {
|
if (error instanceof AppError) {
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import { AppError } from "@/utils/errors";
|
|||||||
import { getErrorMessage } from "@/utils/errors";
|
import { getErrorMessage } from "@/utils/errors";
|
||||||
import type { NextRequest } from "next/server";
|
import type { NextRequest } from "next/server";
|
||||||
import logger from "@/lib/logger";
|
import logger from "@/lib/logger";
|
||||||
export const revalidate = 60;
|
|
||||||
|
|
||||||
const DEFAULT_PAGE_SIZE = 20;
|
const DEFAULT_PAGE_SIZE = 20;
|
||||||
|
|
||||||
@@ -26,14 +25,7 @@ export async function GET(
|
|||||||
SeriesService.getSeries(seriesId),
|
SeriesService.getSeries(seriesId),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return NextResponse.json(
|
return NextResponse.json({ books, series });
|
||||||
{ books, series },
|
|
||||||
{
|
|
||||||
headers: {
|
|
||||||
"Cache-Control": "public, s-maxage=60, stale-while-revalidate=120",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error({ err: error }, "API Series Books - Erreur:");
|
logger.error({ err: error }, "API Series Books - Erreur:");
|
||||||
if (error instanceof AppError) {
|
if (error instanceof AppError) {
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import type { KomgaSeries } from "@/types/komga";
|
|||||||
import { getErrorMessage } from "@/utils/errors";
|
import { getErrorMessage } from "@/utils/errors";
|
||||||
import type { NextRequest } from "next/server";
|
import type { NextRequest } from "next/server";
|
||||||
import logger from "@/lib/logger";
|
import logger from "@/lib/logger";
|
||||||
export const revalidate = 60;
|
|
||||||
|
|
||||||
export async function GET(
|
export async function GET(
|
||||||
request: NextRequest,
|
request: NextRequest,
|
||||||
@@ -16,11 +15,7 @@ export async function GET(
|
|||||||
const seriesId: string = (await params).seriesId;
|
const seriesId: string = (await params).seriesId;
|
||||||
|
|
||||||
const series: KomgaSeries = await SeriesService.getSeries(seriesId);
|
const series: KomgaSeries = await SeriesService.getSeries(seriesId);
|
||||||
return NextResponse.json(series, {
|
return NextResponse.json(series);
|
||||||
headers: {
|
|
||||||
"Cache-Control": "public, s-maxage=60, stale-while-revalidate=120",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error({ err: error }, "API Series - Erreur:");
|
logger.error({ err: error }, "API Series - Erreur:");
|
||||||
if (error instanceof AppError) {
|
if (error instanceof AppError) {
|
||||||
|
|||||||
Reference in New Issue
Block a user