#To cache a build or not to cache a build, that is the question.

1 messages · Page 1 of 1 (latest)

wispy whale
#

In this discussion about monorepos, an issue about how a monorepo handles build caching with NextJS came up and reinvigorated a question that had popped up into my mind some time ago, but forgot to ask.

Monorepo managers like Nx, Turborepo and Rush all try to cache build outputs, so that CI runs can be more performant. As I understand Dagger, that is also the purpose of its cache.

So, would having both cache schemes "turned on" be doubled effort and thus wasted resources?

twilit mango
#

So, would having both cache schemes "turned on" be doubled effort and thus wasted resources?

It really depends on what type of caching each solution does. A very trivial example is to take node_modules for instance. In Dagger you'd still want to use Dagger's cache along with node_modules cache since they complement each other quite nicely. If, for example, you're building an app that produces an OCI image which requires several steps to happen in order to get to that state, having both caches will be quite beneficial.

AFAIK turborepo Nx and all those kind of solutions are very targetted to the application build output. In a Dagger pipeline there's generally more things around that flow which is installing the necessary tools and then bundling the app in either an OCI image or something else that will be benfitted of using the Dagger cache

#

not sure if that makes sense @wispy whale

wispy whale
#

I forgot to link the discussion, which I've done above. Not sure it will change your answer. Probably not.

So, can I put it this way?

If there is a container as an artifact of a CI workflow, Dagger's cache will make sure the building of that container will be as quick as possible.

If there is internal cache used in the building or even testing of the application, that is what the monorepo will handle and thus, should also be used.

twilit mango
#

I'd just generalize it that it's generally benficial to use both caches always. Since Dagger is a tool that's designed to "wrap" other tools, you'll get the maximium performance if you use both Dagger's and your tools cache