Skip to main content

CacheCustom

This allows you to create your own caching strategy, using any of the options available in a CachingStrategy object.

Learn more about data fetching in Hydrogen.

Anchor to overrideOptions
overrideOptions
required

Examples
import {CacheCustom} from '@shopify/hydrogen';

export async function loader({context}) {
const data = await context.storefront.query(
`#grahpql
{
shop {
name
description
}
}
`,
{
cache: CacheCustom({
maxAge: 60 * 60 * 24 * 365,
staleWhileRevalidate: 60 * 60 * 24 * 7,
}),
},
);

return data;
}


Was this page helpful?