Site takes longer to build with the cache than without

So my site currently takes about 1m30s to build with the cache.

If I run the build with cache cleared it takes 1m10-20s.

Something seems wrong here…

25 seconds to fetch and extract the ~1GB cache
8 seconds to install poetry
35 seconds to install my project dependences with poetry

Is there any way to reduce the size of the cache so it doesn’t take as long to fetch? Can I somehow see what is making it so big?

Can I avoid having to install poetry every single build?
Can I cache the installed python dependencies (rather than just pip cache) to avoid installing them from scratch each build, instead letting poetry make sure they are in the correct state?

If your builds run in under 2 minutes, congratulations! You are among the top 5% or so of fastest netlify builds already :slight_smile:

However, sorry to say, we probably won’t be able to debug a 15-30 second difference in build time for you, despite it being a large percentage of your build time.

As you’ve noted, caching 1Gb of files and restoring them does take some time in our system - and if your build is very short, it could be much of the time. That however is how you “avoid installing poetry every build”, as far as I know.

Regardless, you’re welcome to remove the cache at the end of your build so we don’t save it, in case that speeds up your build. You can see more details about how and where we store it in our build scripts which are open source: build-image/run-build-functions.sh at focal · netlify/build-image · GitHub