Skip to content

Instantly share code, notes, and snippets.

@wookiehangover
Last active October 4, 2021 17:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wookiehangover/c65065b27a788b8f478307f34d757c26 to your computer and use it in GitHub Desktop.
Save wookiehangover/c65065b27a788b8f478307f34d757c26 to your computer and use it in GitHub Desktop.
  • Dynamic HTML comes from individual bundles compiled for every server rendered page.
    • The contents of each astro template determine if a page is static or dynamic:
      • Static pages output complete HTML documents at build time
      • Dynamic pages output ES Modules that are run on a server
    • Each bundle should be and ES Module that exports a standard interface with methods for creating
      • HTML payloads
        • an entire document for full page requests
        • a partial document for incremental updates
      • a JSON payload with the props for the template
    • Individual bundles makes for an ideal target for serverless functions and makes a path for hybrid CDN + SSR deployments
  • Backend architecture boils down to 3 layers:
    1. An edge service that handles routing. Some routes return cached static content, other routes trigger serverless functions that return dynamic html.
    2. Static file storage / CDN with good cache policies
    3. Serverless functions for:
      • HTML payloads for "full page" requests
      • JSON responses for hydrating client-side rendering
  • How
    • generate a Resource Map of bundles to routes as an intermediate step
    • from the Resource Map , create build files targeting specific cloud hosts, so Astro is both framework and backend agnostic.
      • dev server works similarly but with a virtual file system and incremental compilation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment