perf: optimize Komga caching with unstable_cache for POST requests and reduce API calls
Some checks failed
Deploy with Docker Compose / deploy (push) Has been cancelled
Some checks failed
Deploy with Docker Compose / deploy (push) Has been cancelled
- Fix POST requests (series/list, books/list) not being cached by Next.js fetch cache by wrapping them with unstable_cache in the private fetch method - Wrap getHomeData() entirely with unstable_cache so all 5 home requests are cached as a single unit, reducing cold-start cost from 5 parallel calls to 0 on cache hit - Remove N+1 book count enrichment from getLibraries() (8 extra calls per cold start) as LibraryDto does not return booksCount and the value was only used in BackgroundSettings - Simplify getLibraryById() to reuse cached getLibraries() data instead of making separate HTTP calls (saves 2 calls per library page load) - Fix cache debug logs: replace misleading x-nextjs-cache header check (always UNKNOWN on external APIs) with pre-request logs showing the configured cache strategy - Remove book count display from BackgroundSettings as it is no longer fetched Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -278,7 +278,7 @@ export function BackgroundSettings({ initialLibraries }: BackgroundSettingsProps
|
||||
htmlFor={`lib-${library.id}`}
|
||||
className="cursor-pointer font-normal text-sm"
|
||||
>
|
||||
{library.name} ({library.bookCount} livres)
|
||||
{library.name}
|
||||
</Label>
|
||||
</div>
|
||||
))}
|
||||
|
||||
@@ -34,14 +34,8 @@ export function KomgaSettings({ initialConfig }: KomgaSettingsProps) {
|
||||
const handleTest = async () => {
|
||||
setIsLoading(true);
|
||||
|
||||
const form = document.querySelector("form") as HTMLFormElement;
|
||||
const formData = new FormData(form);
|
||||
const serverUrl = formData.get("serverUrl") as string;
|
||||
const username = formData.get("username") as string;
|
||||
const password = formData.get("password") as string;
|
||||
|
||||
try {
|
||||
const result = await testKomgaConnection(serverUrl.trim(), username, password || config.password);
|
||||
const result = await testKomgaConnection(config.serverUrl.trim(), config.username, config.password);
|
||||
|
||||
if (!result.success) {
|
||||
throw new Error(result.message);
|
||||
@@ -55,8 +49,8 @@ export function KomgaSettings({ initialConfig }: KomgaSettingsProps) {
|
||||
logger.error({ err: error }, "Erreur:");
|
||||
toast({
|
||||
variant: "destructive",
|
||||
title: t("settings.komga.error.title"),
|
||||
description: t("settings.komga.error.message"),
|
||||
title: t("settings.komga.error.connectionTitle"),
|
||||
description: t("settings.komga.error.connectionMessage"),
|
||||
});
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
|
||||
Reference in New Issue
Block a user