Edge Side Includes (ESI) for Cloudflare Workers
Installation:
yarn add esi-cf-workers
Create a middleware, at functions/_middleware.js with the follwing content:
import { withESI } from "esi-cf-workers"
export async function onRequest(context) {
const res = await context.next();
return withESI(res);
}import { withESI } from "esi-cf-workers"
export default {
async fetch(request, env, ctx) {
const res = await fetch(request)
return withESI(res)
},
};