Strapi not working with Nextjs in Prod

Whenever i make changes in strapi they’re updated immediately on my localhost nextjs app, but they dont seem to be appearing in my nextjs production app

I mean i can see the response in the network tab and its the correct one, but the website ui is still not changing

This topic has been created from a Discord post (1228370749102882826) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord

Hi <@726458728575926372> !
Could you provide some more info on your issue - what do you mean when you say that you see the correct response in the network tab? Is this an issue in a server or a client component? If it is the former may it be that you have not set up the nextjs caching to work as you want?
Try skimming through the cache docs ()

Yes i apologize the issue wasn’t from strapi

I didnt think it could be cache because i thought next caches data for like 30 seconds not a whole hour

But i added a 10s revalidation timer on cache and things are working smoothly

This is not the best option to set revalidate so low, it’s best to set it to at list 90 seconds this can spin the CPU up to 100% easily if you get multiple request same time

Alright thanks i’ll up it to 90s

Yea lower it after you finish development, the problem is next optimizes images on each rerender and it’s quite cpu expensive

Hey <@632956853122236457> coming to this after the weekend. Just for my own sake because it interests me - how come that nextjs optimizes images on each rerender? Wont it just use the previous optimized image if the source is the same?

i’m not 100% sure

Adding onto this — you can configure a revalidation endpoint on your NextJS app and configure an authenticated Strapi webhook to POST to it on entity action

I have cache tags defined for each of my NextJS fetch requests and so I use revalidateTag(), but you can easily compose revalidation logic to use revalidatePath() instead/additionally