refactor: optimize ServerCacheService TTL settings for paginated lists and static data to enhance caching efficiency
This commit is contained in:
@@ -94,10 +94,10 @@ size: "1000"; // Récupère TOUS les livres d'un coup
|
|||||||
- Routes API = dynamiques, pas besoin d'ISR
|
- Routes API = dynamiques, pas besoin d'ISR
|
||||||
- Le cache serveur suffit
|
- Le cache serveur suffit
|
||||||
|
|
||||||
- [ ] **2.4 Optimiser les TTL ServerCacheService**
|
- [x] **2.4 Optimiser les TTL ServerCacheService**
|
||||||
- Réduire TTL des listes paginées (1-2 min)
|
- Réduire TTL des listes paginées (2 min) ✅
|
||||||
- Garder TTL court pour les données avec progression (5 min)
|
- Garder TTL court pour les données avec progression (2 min) ✅
|
||||||
- Garder TTL long pour les images (7 jours)
|
- Garder TTL long pour les images (7 jours) ✅
|
||||||
|
|
||||||
**Résultat final :**
|
**Résultat final :**
|
||||||
|
|
||||||
|
|||||||
@@ -19,20 +19,26 @@ class ServerCacheService {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Configuration des temps de cache en millisecondes
|
// Configuration des temps de cache en millisecondes
|
||||||
|
private static readonly oneMinute = 1 * 60 * 1000;
|
||||||
|
private static readonly twoMinutes = 2 * 60 * 1000;
|
||||||
private static readonly fiveMinutes = 5 * 60 * 1000;
|
private static readonly fiveMinutes = 5 * 60 * 1000;
|
||||||
private static readonly tenMinutes = 10 * 60 * 1000;
|
private static readonly tenMinutes = 10 * 60 * 1000;
|
||||||
private static readonly twentyFourHours = 24 * 60 * 60 * 1000;
|
private static readonly twentyFourHours = 24 * 60 * 60 * 1000;
|
||||||
private static readonly oneMinute = 1 * 60 * 1000;
|
|
||||||
private static readonly oneWeek = 7 * 24 * 60 * 60 * 1000;
|
private static readonly oneWeek = 7 * 24 * 60 * 60 * 1000;
|
||||||
private static readonly noCache = 0;
|
private static readonly noCache = 0;
|
||||||
|
|
||||||
// Configuration des temps de cache
|
// Configuration des temps de cache
|
||||||
|
// Optimisé pour la pagination native Komga :
|
||||||
|
// - Listes paginées (SERIES, BOOKS) : TTL court (2 min) car données fraîches + progression utilisateur
|
||||||
|
// - Données agrégées (HOME) : TTL moyen (10 min) car plusieurs sources
|
||||||
|
// - Données statiques (LIBRARIES) : TTL long (24h) car changent rarement
|
||||||
|
// - Images : TTL très long (7 jours) car immuables
|
||||||
private static readonly DEFAULT_TTL = {
|
private static readonly DEFAULT_TTL = {
|
||||||
DEFAULT: ServerCacheService.fiveMinutes,
|
DEFAULT: ServerCacheService.fiveMinutes,
|
||||||
HOME: ServerCacheService.tenMinutes,
|
HOME: ServerCacheService.tenMinutes,
|
||||||
LIBRARIES: ServerCacheService.twentyFourHours,
|
LIBRARIES: ServerCacheService.twentyFourHours,
|
||||||
SERIES: ServerCacheService.fiveMinutes,
|
SERIES: ServerCacheService.twoMinutes, // Listes paginées avec progression
|
||||||
BOOKS: ServerCacheService.fiveMinutes,
|
BOOKS: ServerCacheService.twoMinutes, // Listes paginées avec progression
|
||||||
IMAGES: ServerCacheService.oneWeek,
|
IMAGES: ServerCacheService.oneWeek,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user