Open Jones-S opened 8 hours ago
Great question, and I don't have a great answer on this.
The Durable Caching is actually something that I wouldn't use on my own, typically. It's actually something that a lot of frameworks would build their caching mechanism on (with adapters for hosting on Netlify). I'm pretty sure this is how Astro's Netlify adapter probably works.
I'm not super familiar with Nuxt, but I'd think they'd have some form of caching and granular invalidation built in...
If it's anything like Next, there's probably some mechanism for overall caching built into their API routes. I might look at migrating from a pure netlify on-demand builder to making your API calls via Nuxt API routes to take advantage of their overall caching structure. A quick look on their caching page shows both time-based invalidation and key-based invalidation. I'm not an expert on Nuxt (and honestly not an expert on Netlify's caching, overall), but that would be the direction that I would look. Lean on your framework vs. trying to write it yourself
Hi
I just watched your video on youtube about durable caching: https://www.youtube.com/watch?v=2i5pgXiIQUQ&ab_channel=BryanRobinson
Thanks for the explanation!
I was wondering if you maybe could give me an idea how to achieve the following, as you seem to be knowledgeable about netlify's caching.
I have a CMS from which I use graphql to fetch data an a page basis to display it in a nuxt frontend. For now let caching aside, netlify will not cache dynamic content like the one coming from a CMS as this could change any time. Instead they have a Time To Live: https://docs.netlify.com/configure-builds/on-demand-builders/
What I would like to achieve is, that a normal page is not always using a builder for every page request but rather use a cached version of it. One way, I could imagine to achieve this, is setting a very high TTL and upon page save in the CMS I would like to refresh the TTL, making the next request to the page invoke the on-demand builder again. Only for the changed page though.
This would save resources and also result in fewer function invocations. What I am not sure about is: Can I force reset the TTL?
Now on the netlify docs I see that they suggest using a durable cache instead. And that's how I found your video. In your example you have not only a different setup (I assume there is no on-demand builder in the no-cache version in place?) but also you have written actual functions to serve the data.
Would you have any idea how to do this with graphql (so far I have not written any code to defined functions at all). Nuxt/Netlify is doing this by default.
Maybe this is a bit far fetched to hope that you have an answer ready. Nonetheless I thought I might reach out.
Thanks a lot and have a nice day.