#Incremental caching
3 messages · Page 1 of 1 (latest)
Hi @chilly fox. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
Incremental Content Caching is an experimental feature introduced in Astro 4.0 to significantly speed up build performance for large websites. As a website's codebase grows over time, it often takes longer to build. This problem is even more pronounced for static websites, which regenerate the same pages on every build. To mitigate this, Astro 4.0 introduced caching to reduce the amount of duplicate, unnecessary work done inside the astro build command.
This feature works by hooking into the Content Collections API. Because Astro manages the APIs for accessing and managing your content inside of a collection, it can safely track changes inside of a collection using an internal build manifest. Astro checks the cache on each build and reuses unchanged content entries.
In practical terms, enabling content caching on a real-world codebase saw the relevant step in astro build drop from 133.20s to 10.46s, about 92% faster. The end-to-end build time was reduced from 4mins 58s to just over 60s, for a total build time that was 80% faster.
To enable this experimental feature, you can add the experimental.contentCollectionCache flag to your Astro configuration. If you encounter issues with the stored cache, you can reset your build cache by running the command npm run astro build -- --force.
Sources:
- Astro 4.0 Blog Post (https://astro.build/blog/astro-4#incremental-content-caching-experimental)
- Astro Documentation (https://docs.astro.build/en/guides/content-collections#enabling-build-caching)