Next.js Discord

Discord Forum

Cache deactivation

Unanswered
Northeast Congo Lion posted this in #help-forum
Open in Discord
Northeast Congo LionOP
Hello,

I have a project on a repo with a develop branch and a main branch.
I set up the cache on my project with the following config export const revalidate = 172800; // 48h. Everything works fine, but I'd like to disable caching on the develop branch but not on main.
I tried the following but NextJS doesn't allow it:

export const revalidate = process.env.NO_CACHE === 'true' ? 0 : 172800;
export const dynamic = process.env.NO_CACHE === 'true' ? 'force-dynamic' : 'auto';


I haven't figured out how to do it, so if anyone has encountered this problem and has a solution, I'd love your help. Thanks a lot!

6 Replies

Northeast Congo LionOP
@Anay-208 | Ping in replies I'll keep looking and let you know if I find anything too.
There is a complex process, but if you're using Github actions, you can just go to each of the file to change their cache settings
and I'm not sure but maybe you can do it like this:
export const dynamic = (() => process.env.NO_CACHE === "true" ? 0 : 172800)()
@Northeast Congo Lion resolved?