Code Monkey home page Code Monkey logo

Comments (3)

ztanner avatar ztanner commented on June 23, 2024 1

Ahh, I see what you mean @AkifumiSato -- let me take a closer look at why we needed that condition and I'll get back to you!

from next.js.

ztanner avatar ztanner commented on June 23, 2024

Hi @AkifumiSato -- the names "static" and "dynamic" do not relate to the page rendering type, but rather different categories of "liveness" that can be configured. The actual heuristic of whether to use dynamic or static is based on the prefetch prop. From the docs:

The dynamic property is used when the prefetch prop on Link is left unspecified.
The static property is used when the prefetch prop on Link is set to true, or when calling router.prefetch.

The different properties of this config refer to variable levels of "liveness" and are unrelated to whether the segment itself is opting into static or dynamic rendering. In other words, the current static default of 5 minutes suggests that data feels static by virtue of it being revalidated infrequently.

So in this case, static will influence:

  • How long a loading.js segment is held onto before being refetched from the server
  • How long a segment with prefetch={true} will be held onto before being refetched from the server.

If you modify the Link components to have prefetch={true}, you'll see that your static staleTime property is used.

Let me know if I misunderstood your question!

from next.js.

AkifumiSato avatar AkifumiSato commented on June 23, 2024

@ztanner Thank you for response.

The dynamic property is used when the prefetch prop on Link is left unspecified.

I tried with prefetch={undefined} for a static rendered page and staleTimes.static was applied until the cache was first used. After the second time, staleTimes.dynamic is applied. This seems to be caused by isFirstRead.

prefetchValues.status === PrefetchCacheEntryStatus.stale &&
!mutable.onlyHashChange &&
!isFirstRead

I think the documentation needs to be changed to describe up to the first use of the cache or to a simpler specification. What do you think?

from next.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.