Next.js Discord

Discord Forum

Fetch cache based on headers

Unanswered
Indian mackerel posted this in #help-forum
Open in Discord
Indian mackerelOP
I would like to have cache assigned to my custom header

My custom header is:
x-store-header

I would like the cache to not be shared between queries with different cache.

So if I call:
fetch("www.something.com/xyz?abc=123",{
  headers:{
  x-store-header:'randomStore'
}, 
  next: {
      revalidate: 60,
    })

and then I call
fetch("www.something.com/xyz?abc=123",{
  headers:{
  x-store-header:'randomStore2'
}, 
  next: {
      revalidate:60,
    })


I would like it to not share the cache

5 Replies

Indian mackerelOP
I would love to have something like key inside of the fetch cache itself, unstable cache lets me create my own cache
They use the same cache method effectively... Also nextjs wants to remove the fetch cache anyway and make it into a manual...
Indian mackerelOP
That is interesting, could you give me a source @riský , I would love to read more about it