Coder Social home page Coder Social logo

Comments (2)

ShubhamOulkar avatar ShubhamOulkar commented on June 28, 2024

Use only-cache:-

This option sets 'force-cache' if no option is provided on fetch() request.
Where as default-cache sets 'force-cache' if no option is provided on fetch() request but it consider as static even after dynamic functions.

Use following in next-canary only (this creates dynamic rendering with cached data)

export const fetchCache = "only-cache";

Don't need to use fetchCache option in Next 14 because fetch() cached by default, use of dynamic functions will render dynamically.

from next.js.

willemmulder avatar willemmulder commented on June 28, 2024

@ShubhamOulkar Thanks, but I'm not sure if I understand correctly. So what I want is that all requests (also those after dynamic functions) are always cached (unless they specifically opt out using no-store), but that the cache is invalidated every 5 minutes. How would I do that in Next 14?

Note that I do use cookies/sessions/auth, so the functions are always rendered dynamically, but I do want the requests to be cached for 5 minutes.

What do you mean with the "but it consider as static even after dynamic functions." part?

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.