Conversation
|
One small datapoint in favor of the currently experimental content cache: Audiobookaneers.com build: 21:10:55 [build] 5904 page(s) built in 170.55s 21:13:36 [build] 5904 page(s) built in 118.22s Second build was more than 50 seconds (about 30%) faster. I'm hoping to see similar improvements on the Cloudfront side now that they have a "beta" build cache as well, but so far the gains are a bit more minimal (from 2m24s to 1m54s, though this DID include changes to 3 posts content, though not new posts/tags/etc) and their beta build cache only seems to be holding onto In the "best case scenario" when I add a post to /src/content/posts, the following pages would need to be rebuilt:
I tell you what, this has discouraged me from implementing a 'recent posts' sidebar widget into the static build, as that would mean that every single page on the site would need to be regenerated. I'll definitely just use client-side JS for that! And it makes me think about investigating the "hybrid" approach for the pagination as this would cut down a lot of what needs to be rebuilt. |
|
Build caching idea: //Return a page hash, unique for each page variation
export function getHash() {
//return CMS.pageVersion;
//return CMS.lastUpdateTime;
//return null; //Always rebuild - Sitemap etc
return Astro.props; //Default
}
//OR
export async function getStaticPaths() {
return [
{ hash : /* required for partial building, null by default */ ,params: { /* required */ } ,props: { /* optional */ } },
];
}
---
TEMPLATEIf every page had a function (similar to getStaticPaths) called getHash that produced a unique hash for a particular page, then on a new build a list of the previous hashes and new hashes could be compared and only the ones with different hashes would be built. This assumes that the output HTML is deterministic based of its inputs, for example the default implementation of getHash would return: sha256(Astro.props).
|
|
|
|
||
| # Background & Motivation | ||
|
|
||
| The original [incremental build support](https://github.com/withastro/roadmap/discussions/237) proposal is one of our oldest and most highly upvoted issues. The corresponding [roadmap issue](https://github.com/withastro/roadmap/issues/698) has likewise recieved a lot of attention and positive feedback. From the extensive performance profiling we've done, we know that Rollup is the main bottleneck in Astro's build process. |
There was a problem hiding this comment.
| The original [incremental build support](https://github.com/withastro/roadmap/discussions/237) proposal is one of our oldest and most highly upvoted issues. The corresponding [roadmap issue](https://github.com/withastro/roadmap/issues/698) has likewise recieved a lot of attention and positive feedback. From the extensive performance profiling we've done, we know that Rollup is the main bottleneck in Astro's build process. | |
| The original [incremental build support](https://github.com/withastro/roadmap/discussions/237) proposal is one of our oldest and most highly upvoted issues. The corresponding [roadmap issue](https://github.com/withastro/roadmap/issues/698) has likewise received a lot of attention and positive feedback. From the extensive performance profiling we've done, we know that Rollup is the main bottleneck in Astro's build process. |
| # Goals | ||
|
|
||
| - Improve `astro build` performance | ||
| - Restructure our |
There was a problem hiding this comment.
| - Restructure our | |
| - Restructure our (something?) |
|
|
||
| # Example | ||
|
|
||
| This propsal introduces minimal public API surface changes, but requires many internal implementation details to be updated to support caching in some way. |
There was a problem hiding this comment.
| This propsal introduces minimal public API surface changes, but requires many internal implementation details to be updated to support caching in some way. | |
| This proposal introduces minimal public API surface changes, but requires many internal implementation details to be updated to support caching in some way. |
|
The experimental feature was removed in Astro 5. With the introduction of Content Layer the internals of how Content Collections have changed quite a lot, so how an incremental build could work needs to be rethought. |
|
Incremental builds on demand would be such a game-changer for many large companies and organizations with tens of thousands of static pages. |
|
Do you think its possible to achieve simple ISR using app.render in a custom adapter? Would someone be willing to provide guidance for implementing that? |
Here are a couple of guides to achieving something like ISR even with the regular adapters: |
|
Thanks for the guides, but that's not exactly what I meant. I've already gone over the articles and they either use cache headers with SSR or stale-while-revalidate, or some Netlify specific stuff. What I wish to explore is to build a node adapter (extension? Idk) that would look at incoming requests, determine the requested page, and render it if it has been flagged as revalidate by my revalidate api route. Is this even possible using the app.render() or did I misunderstand the utility? |
|
Ah I see. Yeah, I guess that might work? It might also not be needed if you follow a model more like the first guide link I shared. That shows invalidating the cache based on headers, but adding an endpoint that invalidates the cache for a page instead would also work in that model (and might be a bit easier to implement than rebuilding the adapter?) |
|
That works when you can have a CDN in front of your server, which I believe is enough for the majority of users at this stage of Astro. Thanks for the suggestions. Can't wait for Astro-level ISR tho! 👀 |
|
Hi all, I was wondering if there are any recent updates on this RFC, or if it’s still being actively explored? I’m really looking forward to this feature because I believe Incremental Build, together with the default prerender strategy and the Server Islands architecture, can bring TRUE on-demand ISR capabilities. This could revolutionize medium to large static sites, allowing us to benefit from Astro’s outstanding performance and user experience while unlocking powerful new possibilities. Much respect and thanks to everyone in the Astro team and all contributors for your incredible work and dedication! |
This RFC was specific to our old Markdown/MDX build process prior to Astro 5, so no longer applies. These couple of articles are good ones for how to approach ISR with Astro: |
Really appreciate you pointing me to those articles—I’ll definitely give them a thorough read. In the meantime, I’ve actually been experimenting with leveraging Content Collections together with Server Islands to try and achieve something similar to on-demand ISR. It seems like a promising approach, and I can’t wait to dive deeper and see where it leads. |
Summary
Built-in incremental build support
Links