Skip to content

Performance

  • Indexes: a field can be filtered or sorted in large queries with index: true (it goes to cms_index). Index whatever you filter in lists or on the site.
  • Fetch less: select in find, depth only where it is used, defaultPopulate on collections others populate (e.g. only a category's name and slug), pagination: false only with limit.
  • Light hooks: an afterRead runs on every document read; heavy work goes to a job (cms.jobs.queue).
  • Reusable blocks: config.blocks + blockRef("slug") instead of repeating the same block in many fields.
  • Location: create D1 close to your editors (wrangler d1 create --location …); site reads can be cached in the Astro route (Cache-Control) because published content only changes when someone publishes.
  • Local API over REST: in Astro pages use Astro.locals.cms (no HTTP in between); cms.sudo() only where access rules truly do not apply.