D1, R2 & Resend · Free guide

Fetching data at build time vs. request time with Astro, D1, and R2

Pull reference catalogs, marketing copy, and semi-static lists during Astro build time so visitors load pre-rendered static HTML instantaneously from CDN memory. Reserve live request-time Workers (functions/api/) for user actions—like contact submissions, opt-in downloads, real-time inventory checks, or private signed URLs.

By StaticLaunch · Four Media Group LLC

Build-time pre-rendering (SSG) for maximum speed and SEO

When catalog pricing, service listings, or blog articles change once a day or week, running a fast Astro static rebuild yields instant <50ms edge TTFB and zero database reads per visitor.

Request-time edge endpoints for interactive visitor actions

Anything personalized per request—saving form inputs into D1, sending transactional confirmation via Resend, or verifying gated receipts—runs dynamically in lightweight Pages Functions.

Hybrid pattern: static HTML shell + selective fetch()

Serve static SEO-rich product or template pages directly, then let minimal browser JS fetch /api/availability or submit forms dynamically only when visitors interact.

Common questions

If I stay on Astro output: 'static', can /functions/api/ routes still run dynamically?

Yes! On Cloudflare Pages, files inside your root functions/ directory deploy as dynamic Workers automatically even when Astro builds 100% static HTML into dist/.

How fast do Cloudflare Deploy Hooks rebuild static content after data changes?

Typical small-to-medium Astro static builds finish and propagate globally within 30 to 90 seconds.

References

Provider interfaces and limits can change. Consult the original documentation before changing production settings.