Next.js Discord

Discord Forum

Cache between authenticated users

Unanswered
Curly-Coated Retriever posted this in #help-forum
Open in Discord
Curly-Coated RetrieverOP
I've a doubt about cache. How can I share it between authenticated users? I've a request with same response for authenticated users and I want to cache it. How can I do it? Because the Authorization on headers is used for cache key. I've searched a lot and I haven't found an answer about it.

I've found some github issues without final answer from vercel team.

https://github.com/vercel/next.js/discussions/51279
https://github.com/vercel/next.js/discussions/76875

A similar scenario An authenticated store, where the product data is the same for all users but confidential. Users must be authenticated to view it, but I’d like to cache the response to avoid hitting the backend on every request.

How to handle it? It's a common case for me and seems anyone cared about it.

2 Replies