Using Edge-Side Includes with Workers for High Availability
Aug 28, 2018Guest Author

Summary
This post introduces the use of Cloudflare Workers to implement Edge Side Includes (ESI) for dynamic content assembly and graceful fallback mechanisms. The worker fetches the origin response, identifies fragments specified in 'X-Fragments' headers, and prefetches these fragments concurrently with a shared timeout. It then streams the origin response, replacing fragment placeholders with prefetched content or falling back to content within HTML comments if a fragment fails to load within the timeout. This enables partial rewrites and high availability during backend migrations.