Tech Tip #17: Serve static sites from the edge

A page view shouldn't need a database.

Video created by explainapaper.com

The problem

Content sites often run an application server and a database for every page view, even though the pages change rarely.

The fix you can use today

  • Pre-render pages that rarely change as static files.
  • Serve them from a CDN or edge network with long cache lifetimes.
  • Keep server-side code only for things that really are dynamic, like forms.

GreenCode moved its own website from WordPress to static pages served from the edge.

Tools that help

  • Greencheck (Green Web Foundation): checks whether a domain is hosted on renewable-powered infrastructure
  • CO2.js (Green Web Foundation): an open-source library that turns bytes transferred into an estimate of CO2, using the Sustainable Web Design model
  • WebPageTest: loads a real page and shows every request, its size and when it loaded

How GreenCode helps

GreenCode helps tackle this by proving it on greencode.ai first: static pages on an edge network, WebP images and scripts only where used. A first view of the home page fell from 6,766 KB over 80 requests to 1,719 KB over 33. More on this.

Tags

#cdn#caching

Sources

Transcript

A page view should not need a database. Many content sites build every page fresh, for every visitor. An app server runs code, and a database answers queries. Yet the pages themselves change only now and then. That is work repeated on every single view. Here is the fix you can use today. Build pages that rarely change as plain static files. Serve them from a content delivery network, close to your visitors. Give them long cache lifetimes. Keep server code only for parts that really change, like forms. GreenCode moved its own website from WordPress to static pages served from the edge. Check the result using tools like Greencheck, CO2.js and WebPageTest. They check for green hosting, estimate carbon from bytes, and show every request. GreenCode helps tackle this by proving it on its own site first. Its home page fell from six point eight megabytes to one point seven. That was GreenCode Tech Tip number seventeen. Follow for the next tip, and find more on greencode.ai/tech-tips.

All GreenCode Tech Tips · All GreenCode videos

  • Tip #17
  • For Ops and infrastructure
  • Length 1:07
  • Category Web and front-end
GreenCode

Want this checked on your own system? Talk to the GreenCode team.

Get in touch