#Cache response from CMS in development

7 messages · Page 1 of 1 (latest)

amber nova
#

Hi,
I'm trying to reduce the number of API calls to my CMS when in development, currently each save and refresh grabs fresh data using fetch. It looks as though the docs say fetch calls are automatically cached, but if I test this by updating the CMS, when I refresh fresh data is fetched.

Does the development server behave differently to production?

Gpt4:
https://discord.com/channels/752553802359505017/1101775561396850718

#

this is my fetch function:

export const newFetch = async(groq:string) => {
  const url = `https://${projectId}.api.sanity.io/v${apiVersion}/data/query/${dataset}?query=${encodeURIComponent(groq)}`
  return await fetch(url,{
    headers: {
      "Authorization": `Bearer ${process.env.SANITY_API_TOKEN}`,
    }
  }).then(res => res.json())
}
amber nova
#

Ok... something seems odd. Found a demo by vercel and recreated it, and the data doesnt cache:
https://www.youtube.com/watch?v=gSSsZReIFRk?t=618

@leerob, VP of Developer Experience at Vercel, explains new concepts and foundations of Next.js app router, including layouts, dynamic routes, and data fetching. Deploy today: https://vercel.fyi/app-router

Timestamps:
0:00 Introduction
0:10 Routing
2:57 Dynamic route segments
4:53 Data fetching
7:36 Caching
11:42 Metadata

Learn more
◆ Routing:...

▶ Play video
amber nova
#

Ok, looks like it doesnt work in 13.3.2 but canary is ok 🙏

tranquil ferry
#

Hey just found ur post, im actually looking into this awell atm and it doesnt seem to get cached, did you find another method for it?

amber nova
tranquil ferry
#

Hmm it did not work for me because of the reason it has Authorization and its a GET