On Demand Builders Endpoint [.netlify/builders/... vs .netlify/functions/...]

We have many sites deployed with a nuxt (nitro) server with netlify_builder preset.

In our _redirects file, we still hit our function (which is called server) like this: /* /.netlify/functions/server 200 and it works correctly, meaning that it does run the function and return the HTML correctly, it also seems to us that it caches the result correctly, but not indefinitely.

We double-checked ODB docs, and we acknowledged that we need to hit the function like this: /* /.netlify/builders/server 200 to correctly leverage ODB functionalities.

So, the main question is this: did we correctly assume that hitting via the “functions” folder still retain some kind of cache but with a TTL (when exporting a builder(handler) function) or was it a fluke/we misread logs?
What are the main differences when hitting a function that exports a builder(handler) handler through the functions folder vs the builder folder?

Hiya @AtomsDevs and sorry to be slow with an answer! I am pretty sure this is correct, but I will ask my colleague @hrishikesh to confirm for us tomorrow, since he is my team’s expert on how those functions work.

I believe that:

  • a builder function is cached across our CDN for the TTL specified in the configuration after it is first run. This cache will be ~cleared~ invalidated by a new deploy, much like our file cache.
  • a builder function will return this (stale!) cached value even after to the first request after the TTL expires - while the first re-request runs and the result is re-cached. This is something like the “stale-while-revalidate” pattern becoming popular in dynamic frameworks.
  • I do not know what is intended to happen if you try to create a builder function and access it via the .../functions/... path. I’d suggest…not doing that, rather than relying on the behavior of doing that.

I’m not certain this addresses your concerns/question, so let me know what you think or if this doesn’t make sense, or if this seems to block you accomplishing some goal - and we can escalate to our frameworks team for their advice.