Same build times regardless of cache

I’m using eleventy-fetch on a static Astro build hosted on Netlify.

Whether I build with/out cache, my times are still reflecting a non-cache build. Locally, an uncached site takes ~1.5 min to build, while the same cached version only takes 5 seconds.

I’ve installed netlify-plugin-cache and added this to netlify.toml:

[[plugins]]
package = "netlify-plugin-cache"
  [plugins.inputs]
  paths = [".cache"]

After my deploy has completed, the Netlify log states Successfully cached: .cache ... 195 files in total.
Yet, no matter how many times I redeploy the site, I still get ~1.5 minutes. Therefore, I don’t think it’s rebuilding from the .cache directory. Besides, when I download a specific deploy that should be cached, there is no hidden .cache directory on my local machine.

Is there something more required to make this work?

It actually looks like Netlify does not pull the cached images from the built _astro directory. Instead, it regenerates them on every build.

So, is there a simple way to reference these cached assets instead of Netlify transforming them every time?

I tried this, and failed:

[build.processing]
  # Preserve cache between builds
  [build.processing.cache]
    paths = [
      "_astro/**",
      "node_modules/.astro/assets/**"
    ]

It’s up to the Astro Netlify adapter to save/restore cache. Our Next.js Runtime does it, for example: next-runtime/src/build/cache.ts at main · netlify/next-runtime · GitHub.

I think the adapter only pertains to SSR, not static? In any case I got it working by adding the “node_modules/.astro” directory to the netlify plugin cache module. It cut the time down to just 30 seconds from 1.5 minutes. In the Netlify deploy log I now see reused cache entry next to each previously transformed image.

[build]
publish = "dist"
command = "bun run build"
[[plugins]]
package = "netlify-plugin-cache"
  [plugins.inputs]
  paths = [".cache", "node_modules/.astro"]