ISG aging rules in Stati

Rebuild new posts often and old ones rarely, and the catch on a static host.

SNP 112 #61B Filed stati isg

typescript
isg: {
  // Pages without a publish date
  ttlSeconds: 21600,
  // Older than a year: only rebuilt when they or their templates change
  maxAgeCapDays: 365,
  aging: [
    { untilDays: 1, ttlSeconds: 300 }, // first day: every 5 minutes
    { untilDays: 7, ttlSeconds: 3600 }, // first week: hourly
    { untilDays: 30, ttlSeconds: 86400 }, // first month: daily
    { untilDays: 365, ttlSeconds: 604800 }, // then weekly
  ],
},

A page's age counts from its publishedAt. Stati takes the first rule whose untilDays covers it, uses ttlSeconds for pages without a date, and stops rebuilding a dated page for its age once it's older than maxAgeCapDays. A page can set its own ttlSeconds in front matter.

The config is checked when it loads, and these stop the build: rules out of ascending order, an untilDays that appears twice or is larger than maxAgeCapDays, and a rule with a ttlSeconds over 30 days.

The catch is that this is build-time caching. Nothing happens on the server when a TTL runs out; the TTL only decides what the next stati build renders again. On a static host, refreshing pages over time takes a scheduled build: a cron job, a scheduled CI run or a deploy hook.

In the Stati docs: Aging rules, Maximum age cap and Incremental Static Generation.