Skip to content

Latest commit

 

History

History
33 lines (20 loc) · 1.56 KB

0006-next-cache-and-storyblok-api.md

File metadata and controls

33 lines (20 loc) · 1.56 KB

6. Next cache and Storyblok API

Date: 2024-10-23

Context

Save on API calls and build time by caching the Storyblok API responses

Decision

Provide a Nextjs cached and uncached option for developers to fetch from the Storyblok API through utility functions. The utility functions will have sensible defaults and allow developer to opt in to them. Developers are encouraged to use the utility functions and to create their own cached versions as well.

We are still using the Storyblok API cache through the storyblok js client as it handles cache invalidation 'automagically'.

Storyblok API Cache

Storyblok JS Client Cache

Nextjs Unstable Cache

We have added a 'patch' to the Netlify config to bypass the 2MB limit of the default unstable_cache. This little 'hack' simply re-imports the existing cache handler. vercel/next.js#48324 (comment)

Consequences

  • Caching in Nextjs should help mitigate against multiple API calls for the same thing on a single build
  • Developers will need to opt-in to using the cache as it is not a default
  • The utility functions are caching 'indefinitely' as they should be cleared on every build.
  • Had to 'hack' the default cache handler to support responses greater than 2MB.