Astro build cache not saving/restoring

Hi hi hello :) I host a personal image gallery built with Astro on Pages, which naturally contains a bunch of images that get optimized into a few different variants during the build stage, using the built-in getImage utility. Astro caches these files in the node_modules/.astro/assets directory so subsequent builds don't need to re-optimize everything from scratch. Pages is supposed to upload and restore the node_modules/.astro directory as long as build caching is enabled, you're using v2, etc. and also if it detects "astro" as a dependency (or something like that). However, in my case, it is not doing this, resulting in build times of ~17 minutes every time. There is another ticket from late last year about this problem but it seems to be a separate issue: https://discord.com/channels/595317990191398933/1147209870773330030
3 Replies
cowslaw
cowslaw•4d ago
I have confirmed that the images are properly being saved to the Astro cache directory by changing the build command:
# first build
# after this build, node_modules/.astro/assets contains the cached images
astro build && ls -lhR node_modules/.astro

# another build (tweaked pnpm run build command)
# the ls fails, because the files are either not being uploaded or restored
ls -lhR node_modules/.astro && astro build
# first build
# after this build, node_modules/.astro/assets contains the cached images
astro build && ls -lhR node_modules/.astro

# another build (tweaked pnpm run build command)
# the ls fails, because the files are either not being uploaded or restored
ls -lhR node_modules/.astro && astro build
So despite them being saved to the astro cache dir, they aren't being saved between builds. The pages buildbot does not say which or how many files it's caching, it only says the following after the build completes:
2024-06-23T22:23:56.751708Z Success: Dependencies uploaded to build cache.
2024-06-23T22:23:56.835813Z Success: Build output uploaded to build cache.
2024-06-23T22:23:56.751708Z Success: Dependencies uploaded to build cache.
2024-06-23T22:23:56.835813Z Success: Build output uploaded to build cache.
...which isn't very helpful, so I can't tell if they are not being uploaded in the first place, or if they are being uploaded but not downloaded correctly. I should note that the caching does work locally on two computers and my VPS, so I don't think it's an Astro thing as far as I can tell. e.g. building locally with the cache takes only 8 seconds vs 17 minutes without the cache. I do have full build logs available that I can send via DM, as well as any other info/files that might help debug. But I am just curious if there's anything I'm missing, because Pages build cache for Astro projects has certainly worked for me before. Thanks in advance! Is it rude to bump a thread? 😭 lol
Vero
Vero•3d ago
Hey. Can you please share the logs and deployment ID? ?pages-deployment-id
Flare
Flare•3d ago
The Pages deployment ID is a unique build identifier. It's the UUID in the browser bar (for example, a URL would be dash.cloudflare.com/ACCOUNT_ID/pages/view/PROJECT/DEPLOYMENT_ID where the deployment ID looks something like a398d794-7322-4c97-96d9-40b5140a8d9b). This ID can help troubleshoot some issues with Pages builds so if you have a failing build make sure you grab that ID for the team to use.