0
0
Astroframework~10 mins

Incremental builds with data in Astro - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Incremental builds with data
Start Build
Check Data Changes?
NoSkip Build for Unchanged Pages
Yes
Fetch Updated Data
Generate Only Changed Pages
Update Build Cache
Finish Build
The build process checks if data changed, then only rebuilds pages with updated data, skipping unchanged ones to save time.
Execution Sample
Astro
const pages = ['home', 'about', 'blog'];
const changedPages = ['blog'];
for (const page of pages) {
  if (changedPages.includes(page)) {
    buildPage(page);
  }
}
This code rebuilds only pages that have changed data, skipping others.
Execution Table
StepPageData Changed?ActionOutput
1homeNoSkip buildNo output
2aboutNoSkip buildNo output
3blogYesBuild pageblog page rebuilt
4End--Build complete, only blog rebuilt
💡 All pages checked; only 'blog' had data changes, so only it was rebuilt.
Variable Tracker
VariableStartAfter Step 1After Step 2After Step 3Final
page-homeaboutblog-
changedPages['blog']['blog']['blog']['blog']['blog']
buildStatus{}{home: 'skipped'}{home: 'skipped', about: 'skipped'}{home: 'skipped', about: 'skipped', blog: 'built'}{home: 'skipped', about: 'skipped', blog: 'built'}
Key Moments - 2 Insights
Why does the build skip some pages even though they exist in the pages list?
Because the build checks if the page's data changed (see execution_table steps 1 and 2). If not changed, it skips rebuilding to save time.
How does the build know which pages to rebuild?
It uses a list of changedPages (see variable_tracker 'changedPages') and rebuilds only those pages included in that list.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what action is taken for the 'about' page at step 2?
ASkip build
BBuild page
CFetch data
DUpdate cache
💡 Hint
Check the 'Action' column for step 2 in the execution_table.
At which step does the build process rebuild a page?
AStep 1
BStep 2
CStep 3
DStep 4
💡 Hint
Look for 'Build page' in the 'Action' column in execution_table.
If 'about' page data changed too, how would the buildStatus change after step 2?
A{home: built, about: built}
B{home: skipped, about: built}
C{home: skipped, about: skipped}
D{home: skipped, about: built, blog: built}
💡 Hint
Refer to variable_tracker and imagine 'about' added to changedPages list.
Concept Snapshot
Incremental builds check which pages have updated data.
Only those pages are rebuilt.
Others are skipped to save time.
This speeds up the build process.
Use a list of changed pages to control rebuilds.
Full Transcript
Incremental builds with data means the build system looks at which pages have new or changed data. It then rebuilds only those pages, skipping the rest. This saves time and resources. In the example, three pages exist: home, about, and blog. Only the blog page has changed data, so only it is rebuilt. The buildStatus variable tracks which pages were built or skipped. This approach makes building faster by avoiding unnecessary work.