-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incremental Build RFC #763
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 */ } },
];
}
---
TEMPLATE If 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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! 👀 |
Summary
Built-in incremental build support
Links