fix(cms): adjust caching behavior for development environment
Deploy / verify (push) Successful in 38s
Deploy / deploy (push) Failing after 57s

- Modified cached function to bypass caching in development mode.
- Updated fetchOpenApi function to return cached data only if not in development mode, ensuring accurate API fetching during development.
This commit is contained in:
Peter Meier
2026-04-19 14:09:26 +02:00
parent 2e0601e178
commit 4ec2aa10ec
2 changed files with 6 additions and 3 deletions
+2 -1
View File
@@ -77,6 +77,7 @@ async function cached<T>(
key: string,
fn: () => Promise<T>,
): Promise<T> {
if (import.meta.env.DEV) return fn();
const hit = cache.get(key);
if (hit && hit.expires > Date.now()) return hit.value as T;
const pending = inflight.get(key) as Promise<T> | undefined;
@@ -122,7 +123,7 @@ export function cacheStats(): { size: number; keys: string[] } {
* Wird gecacht (einmal pro Request/Build).
*/
export async function fetchOpenApi(): Promise<OpenApiSpec> {
if (openApiCache) return openApiCache;
if (openApiCache && !import.meta.env.DEV) return openApiCache;
const base = getBaseUrl();
const res = await fetch(`${base}/api-docs/openapi.json`);
if (!res.ok) {
+4 -2
View File
@@ -96,6 +96,7 @@
<div class="flex items-center justify-between container-custom py-2">
<a
href="/"
aria-label={t(T.site_name_fallback)}
class="logo flex items-center origin-left font-bold text-lg tracking-wide hover:scale-[1.12] transition-transform duration-200 ease-out relative"
>
{#if logoSvgHtml}
@@ -178,9 +179,10 @@
</button>
<button
type="button"
class="p-2 -mr-2 hover:bg-stein-0/10 rounded-md transition-colors aria-expanded={menuOpen} flex items-center justify-center"
class="p-2 -mr-2 hover:bg-stein-0/10 rounded-md transition-colors flex items-center justify-center"
aria-label={menuOpen ? t(T.header_menu_close) : t(T.header_menu_open)}
aria-controls="mobile-nav"
aria-controls={menuOpen ? "mobile-nav" : undefined}
aria-expanded={menuOpen}
onclick={toggleMenu}
>
<span class="sr-only"