Next.js Discord

Discord Forum

App Router, Render a static Header at build

Unanswered
European anchovy posted this in #help-forum
Open in Discord
European anchovyOP
I'm working on my site which has a very complicated header component that is not performant to run on the server on each request. Typically, I could let Next cache and we'd be good. However, I have a product query that needs to run and not be cached so I have forced it to be dynamic which prevents caching. As such, the expensive header IS being server side rendered. Is there a way for me to generate the HTML for the header at build and inject the output into my page whilst still having my app not be cached. Alternatively, is there a way to prevent specific components from being cached without preventing the entire route from being dynamic?

0 Replies