diff --git a/src/cache/pageCache.ts b/src/cache/pageCache.ts new file mode 100644 index 0000000..f527a14 --- /dev/null +++ b/src/cache/pageCache.ts @@ -0,0 +1,22 @@ +import { getLogger } from "src/utils/logger"; + +class PageCache { + private readonly logger = getLogger("[PageCache]"); + private readonly cache = new Map(); + + get(url: string): Response | undefined { + const cachedPage = this.cache.get(url); + if (cachedPage) { + this.logger.log("Retrieved cached page for", url); + return cachedPage?.clone(); + } + return; + } + + set(url: string, response: Response) { + this.cache.set(url, response.clone()); + this.logger.log("Cached response for", url); + } +} + +export const pageCache = new PageCache(); diff --git a/src/components/AppLayout/components/Html.astro b/src/components/AppLayout/components/Html.astro index 594b4eb..6d537fc 100644 --- a/src/components/AppLayout/components/Html.astro +++ b/src/components/AppLayout/components/Html.astro @@ -8,6 +8,7 @@ import type { EndpointVideo, } from "src/shared/payload/payload-sdk"; import { contextCache } from "src/cache/contextCache"; +import { PostProcessingTags } from "src/middleware/postProcessing"; interface Props { openGraph?: @@ -47,7 +48,7 @@ const isIOS = parser.getOS().name === "iOS"; ( {`${id} (${formatCurrency(id)})`} @@ -35,7 +37,7 @@ const { currentCurrency } = Astro.locals;