From 9e7056574816ef3bbe5edf374e483d26a1edaac4 Mon Sep 17 00:00:00 2001 From: hamid zarghami Date: Wed, 8 Jul 2026 10:37:41 +0330 Subject: [PATCH] update cache --- src/components/background/PatternBackgroundProvider.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/background/PatternBackgroundProvider.tsx b/src/components/background/PatternBackgroundProvider.tsx index 7fcb142..53dc7e0 100644 --- a/src/components/background/PatternBackgroundProvider.tsx +++ b/src/components/background/PatternBackgroundProvider.tsx @@ -158,19 +158,19 @@ export function PatternBackgroundProvider({ children }: { children: ReactNode }) cached.patternDataUrl; if (cacheHit) { + // Serve cached pattern immediately, then revalidate in background. setPatternImageUrl(cached.patternDataUrl!); setThemeCache(restaurantSlug, { ...themeBase, patternDataUrl: cached.patternDataUrl, }); applyCachedThemeToDom(cached); - return; } let cancelled = false; const proxyUrl = `/${restaurantSlug}/api/proxy-svg?url=${encodeURIComponent(themeBase.bgUrl)}`; - fetch(proxyUrl) + fetch(proxyUrl, { cache: "no-store" }) .then((response) => { if (!response.ok) { throw new Error("Failed to fetch background pattern"); @@ -181,7 +181,9 @@ export function PatternBackgroundProvider({ children }: { children: ReactNode }) if (cancelled) return; const dataUrl = svgToDataUrl(colorizeSvg(svg, menuColor)); - setPatternImageUrl(dataUrl); + if (dataUrl !== cached?.patternDataUrl) { + setPatternImageUrl(dataUrl); + } const nextCache = { ...themeBase,