sveltejs / kit

web development, streamlined
https://kit.svelte.dev
MIT License
18.13k stars 1.84k forks source link

add build cache support to cloudflare pages #12301

Open nosovk opened 1 month ago

nosovk commented 1 month ago

Describe the problem

Cloudflare Pages build agent has limits on invocation time. It's usually not a problem, but when img:enhance was introduced things started to change. All images converted to avif on each build, which causes long builds, and time to time build agent can just timeout. We don't face that problem locally, because we have img cache.

Describe the proposed solution

I found that cloudflare has build cache functionality. https://developers.cloudflare.com/pages/configuration/build-caching/#frameworks We can ask CloudFlare to enable caching of image cache in a sveltekit preset (like add adding node_modules/.cache/imagetools to cache)

Alternatives considered

No response

Importance

nice to have

Additional Information

No response

eltigerchino commented 1 month ago

I don't think there's a way to specify what to cache at the moment. Moreover, it wouldn't be SvelteKit-specific, but any projects or packages using vite-imagetools such as @sveltejs/enhanced-img.

Could Cloudflare Pages detect and cache node_modules/.cache/imagetools during the beta period?

cc: @dario-piotrowicz @benmccann