GithubHelp home page GithubHelp logo

Comments (5)

luismeyer avatar luismeyer commented on June 7, 2024 3

I forked your repo and tried without the revalidation time and a revalidatePath call inside the form action. It seems to work now (or are you expecting different results?). Note that when you refresh the page you might see old numbers because the ISR is revalidating the full router cache in the background. I guess that could be avoided with dynamic=force-dynamic but than you loose the benefit of a fast cached response.

Commit: luismeyer/rappelscanner@1c30b1c
Preview: https://rappelscanner-git-feat-kv-luimey.vercel.app/?vercelToolbarCode=QCiZmInmjrleAx6

from storage.

thomaslenaour avatar thomaslenaour commented on June 7, 2024 1

hey @thomaslenaour, could you give some more context on from where you are calling the server action?

I just tried this based on the kv-redis-starter-example and it works just fine: https://kv-redis-starter-lime-rho.vercel.app. I did not set revalidate=60 to opt into ISR though.

Hey @luismeyer, thanks for your response. In fact, here's the implementation I'm working on for a mini project: https://github.com/thomaslenaour/rappelscanner/blob/56402b2571c133f1aa89b708943c12da6ff344e3/app/_actions/product.ts#L52. Indeed, I've already tried playing with the Vercel example and the counter, and it works perfectly.

I feel like I've implemented it correctly, based on the example you mentioned, but I think I might be missing something because I can't get it to work in my project.

The Server Action is called upon form submission, as soon as you click on a "Search" submit button.

from storage.

luismeyer avatar luismeyer commented on June 7, 2024

hey @thomaslenaour,
could you give some more context on from where you are calling the server action?

I just tried this based on the kv-redis-starter-example and it works just fine: https://kv-redis-starter-lime-rho.vercel.app. I did not set revalidate=60 to opt into ISR though.

from storage.

thomaslenaour avatar thomaslenaour commented on June 7, 2024

Incredible! It seems to be working now. I was convinced that I had already tried it with revalidatePath, but it still wasn't working.

Now, it works fine locally (with dockerized Redis) and also works in the Preview environment.

Thank you for your time and for your assistance @luismeyer!

That being said, in an attempt to understand things a bit better: why didn't the change of value occur in my initial code? Apparently, we just added revalidatePath and removed the revalidation time. But that shouldn't have an impact on the incrementation of the scans value, right?

from storage.

luismeyer avatar luismeyer commented on June 7, 2024

Glad I could help :)

I think beforehand you were running into the data cache. @vercel/kv is doing fetch requests to the upstash API and as stated in the the docs all fetch requests are cached by default. revalidatePath is purging the data cache and therefor when you call the action again the increment really happens.

I didn't try it but I think you could even keep the revalidate=60 in you page segment config.

from storage.

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.