Skip to content

upscalesoftware/cloudflare-esi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Edge Side Includes (ESI)

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

Installation

Steps:

  1. Clone the repository
  2. Install Wrangler CLI
  3. Create wrangler.toml:
    name = "esi"
    type = "webpack"
    account_id = "abcdef1234567890abcdef1234567890"
    zone_id = "1234567890abcdef1234567890abcdef"
    route = "example.com/*"
    Replace placeholders with values specific to your project.
  4. Initialize the project
    npm install
  5. Deploy the Worker
    npm run deploy

Usage

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>

Contributing

Pull Requests with fixes and improvements are welcome!

License

Copyright © Upscale Software. All rights reserved.

Licensed under the Apache License, Version 2.0.

About

Cloudflare Worker processing Edge Side Includes (ESI)

Resources

License

Stars

Watchers

Forks

Packages

No packages published