Skip to content
Discussion options

You must be logged in to vote

@icyJoseph
Thank you for your response!

I’ve confirmed that when use cache is not used, the page is built only once at build time.
However, if any part of the page (including layouts) uses use cache, the entire page will be regenerated according to the shortest cache duration among them.

Since it’s not realistic to avoid using use cache across all layouts and components, I solved this by attaching a custom cache only to the parts that I want to be one-time builds.

export default function Page() {
  "use cache";
  cacheLife("infinite");

  return <div>...</div>
}
import type { NextConfig } from "next";

const nextConfig: NextConfig = {
  cacheComponents: true,
  cacheLife: {
    infinite: {

Replies: 4 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@icyJoseph
Comment options

Comment options

You must be logged in to vote
1 reply
@icyJoseph
Comment options

Answer selected by dninomiya
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants