1. Oxygen Edge Caching:
export default function handleRequest(
request: Request,
responseStatusCode: number,
responseHeaders: Headers,
remixContext: EntryContext
) {
return new Response(markup, {
headers: {
"Cache-Control": "public, max-age=300, stale-while-revalidate=3600",
Vary: "Accept-Encoding",
},
});
}
2. GraphQL Caching:
const { page } = await storefront.query(PAGE_QUERY, {
cache: storefront.CacheShort(),
variables: { handle },
});
3. Sub-request Caching:
export function ProductGrid({ collection }: { collection: string }) {
return (
<Suspense fallback={<ProductGridSkeleton />}>
<Await
resolve={storefront.query(PRODUCTS_QUERY, {
cache: storefront.CacheLong(), // 1 hour
variables: { collection },
})}
>
{(products) => <ProductList products={products} />}
</Await>
</Suspense>
);
}