This project implements a Cloudflare Worker that processes Edge Side Includes according to ESI 1.0 specification.
Features:
- Concurrent fetching of
<esi:include>
fragments- Absolute and root-relative resource URLs
- Fallback to alternative URL upon failure
- Recursive ESI template processing
Steps:
- Clone the repository
- Install Wrangler CLI
- Create
wrangler.toml
:Replace placeholders with values specific to your project.name = "esi" type = "webpack" account_id = "abcdef1234567890abcdef1234567890" zone_id = "1234567890abcdef1234567890abcdef" route = "example.com/*"
- Initialize the project
npm install
- Deploy the Worker
npm run deploy
Reuse HTML content across pages of your website.
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<title>Example website</title>
</head>
<body>
<esi:include src="/_header.html" onerror="continue">
<main>Example content...</main>
<esi:include src="/_footer.html" onerror="continue">
</body>
</html>
_header.html
<nav>
<a href="https://example.com/">Home</a>
</nav>
_footer.html
<footer>
Copyright © Upscale Software. All rights reserved.
</footer>
Pull Requests with fixes and improvements are welcome!
Copyright © Upscale Software. All rights reserved.
Licensed under the Apache License, Version 2.0.