from Serroda@lemmy.world to programming@programming.dev on 01 Apr 10:18
https://lemmy.world/post/45022435
crosspost: lemmy.world/post/45022275
Hi
Hello, I created this project with the goal of quickly setting up a template using Nuxt and the “On-demand revalidation” configuration, integrated with a backend (currently only Pocketbase).
While researching, I discovered that “On-demand revalidation” is a very valid option for saving server resources in exchange for having more data in the cache, but this option requires integration with the backend you use in your project.
Workflow
The user visits a page
The server checks if that page exists in the cache
If it exists in the cache, Nitro returns the cached page, and Nitro checks in the background whether the backend data has changed by reviewing “the data block”; since the backend did not send any signal, Nitro returns “the data block” from the cache
If the page does not exist in the cache, it generates a new page, and Nitro checks if there is a “data block” in the cache; if there isn’t, it fetches the data from the backend
Nitro’s configuration ensures that when a fetch is performed, that data is stored in the cache; that “data block” will expire in one week unless the backend sends an event to reset it.
If the data changes on the backend, it sends an event to reset the cache in Nitro
You can run the script with bun, npm or pnpm
Example
npx nurevMore info
codeberg.org/Serroda/nurev#how-it-works
Take a look and let me know what you think
Have a good day!
#programming
threaded - newest