Different intervals for time based revalidation in the same page
Answered
Mini Lop posted this in #help-forum
Mini LopOP
Hello, I'm new to NextJS ISR.
I saw from NextJS docs, it is stated that:
If I have for example, a page consist of list of products (in a card), and there will be a price tag for each product.
I want to revalidate the list of products every 60s, but I want to revalidate the price tags inside it on each request.
Is this possible in NextJS?
I saw from NextJS docs, it is stated that:
If you have multiple fetch requests in a statically rendered route, and each has a different revalidation frequency. The lowest time will be used for all requests. For dynamically rendered routes, eachfetchrequest will be revalidated independently.
If I have for example, a page consist of list of products (in a card), and there will be a price tag for each product.
I want to revalidate the list of products every 60s, but I want to revalidate the price tags inside it on each request.
Is this possible in NextJS?
Answered by "use php"
I'm considering you have a database, and each item contains information about a product.
revalidating just the price makes no sense, if with the same operation, you can revalidate everything.
revalidating just the price makes no sense, if with the same operation, you can revalidate everything.
7 Replies
@Mini Lop Hello, I'm new to NextJS ISR.
I saw from NextJS docs, it is stated that:
> If you have multiple fetch requests in a statically rendered route, and each has a different revalidation frequency. The lowest time will be used for all requests. For dynamically rendered routes, each `fetch` request will be revalidated independently.
If I have for example, a page consist of list of products (in a card), and there will be a price tag for each product.
I want to revalidate the list of products every 60s, but I want to revalidate the price tags inside it on each request.
Is this possible in NextJS?
I'm considering you have a database, and each item contains information about a product.
revalidating just the price makes no sense, if with the same operation, you can revalidate everything.
revalidating just the price makes no sense, if with the same operation, you can revalidate everything.
Answer
Mini LopOP
Thank you for your response. Can I have your opinion, which one is better for an ecommerce app, SSR (revalidate on every request) or ISR (revalidate after some time)?
I personally prefer ISR.
In addition to that, the price should be not be stored on the
In checkout, incase the price is not updated, I like to give the user a feedback to refresh the page, and revalidate all the routes!
In addition to that, the price should be not be stored on the
localStorage (for cart).In checkout, incase the price is not updated, I like to give the user a feedback to refresh the page, and revalidate all the routes!
Mini LopOP
How can I check that the price is not updated? Do I need to make a call from the client side and compare the price?
@Mini Lop How can I check that the price is not updated? Do I need to make a call from the client side and compare the price?
Do some calculations on the server actions/api route to check if the total is matching the total sent by the client
Mini LopOP
Ahhh I see, thank you so much @"use php" 🙏