Next.js Discord

Discord Forum

Cache with dynamic headers

Unanswered
Gray Wagtail posted this in #help-forum
Open in Discord
Gray WagtailOP
How do you cache with dynamic headers? Next caches the same tag for each set of headers. Meaning every time the user changes JWT token, Next sets a new cache and the old remains until it expires.

How do I cache in a way that it kind of ignored headers? So that regardless of headers, all users get the exact same cache entry.

5 Replies

Gray WagtailOP
Imagine you have a cache on one year, this would flood the cache server eventually.
@Gray Wagtail Imagine you have a cache on one year, this would flood the cache server eventually.
Wuchang bream
you can set max cached items to 1000 for example
@Wuchang bream you can set max cached items to 1000 for example
Gray WagtailOP
Well that doesn't solve anything, then you run into the risk of new entries not being created?
It also doesn't solve the issue that users constantly need new cache entries as soon as their JWT token expires (every 15 minutes).
American black bear
What data are you trying to cache? Can you give an example function, and why headers make a problem.