Next.js Discord

Discord Forum

NextJS user-specific content cache

Unanswered
Norwegian Forest Cat posted this in #help-forum
Open in Discord
Norwegian Forest CatOP
How to cache in case I have user specific content. Like list of words that user created. I use drizzle and neondb. As far as I understand, "use cache" is used when 'content for everybody', ex. 'categories'. So, should I use "use cache" or add redis? If redis, which library is stable?

1 Reply

@Norwegian Forest Cat you have a few options but if you are using cache components I would stick to these 2 options :

1. The data is related to one user, I would use 'use cache: private'

2. It is data that may be used by others in an org or data that is the same for every user but each user needs to be authenticated I would pass info to a child function and 'use cache' with a good cache tag ie if it's info to an org then the org must be in the cache tag.

If I remember correctly, option one caches the data in the browser and option two the data can be accessed across deployments.

Avoiding the foot gun of option 2 is if you are checking authentication or any runtime data you have to use cache in a child function

You also have to understand with option two because it is behind runtime data that the entire page will not be static. It will still be served as a dynamic content. Until one user views it and then it will act statically