Repository navigation
Should OSR template include calls to cacheLife? #663
DescriptionShould the OSR template include calls to cacheLife in the cache helper methods (getSitecorePage, getSitecoreDictionary, ...)? According to the NextJS documentation:
The default profile has a Additional informationNo response |
Replies: 1 comment 2 replies
|
Hi there! The helpers use Next.js's default cache profile: The 15 minutes is the revalidation interval, rather than a hard expiration, a subsequent request can serve the cached result while a background refresh runs. Tag-based invalidation can happen sooner. Calling import { cacheLife, cacheTag } from 'next/cache';
export async function getSitecorePage(params: GetSitecorePageParams) {
'use cache';
cacheLife('hours');
// existing fetch and cacheTag calls
}Choose the profile that fits your publishing policy; keep the existing tags for on-demand revalidation. |
Hi there! The helpers use Next.js's default cache profile:
getSitecorePagehas'use cache'andcacheTag, but nocacheLifecall.The 15 minutes is the revalidation interval, rather than a hard expiration, a subsequent request can serve the cached result while a background refresh runs. Tag-based invalidation can happen sooner.
Calling
cacheLifeexplicitly would make the policy clearer, as the Next.js docs recommend. For example, to use thehoursprofile:Choose the profile that fits your publ…