Edge-Side Includes (ESI) is a markup language that enables dynamic content assembly at the CDN edge by instructing edge servers to include content fragments with different cache policies into a single page. It solves the problem of caching highly dynamic pages by allowing a page's static shell to be cached separately from its personalized or time-sensitive components.
Glossary
Edge-Side Includes (ESI)

What is Edge-Side Includes (ESI)?
A markup language for assembling dynamic web pages at the CDN edge by including fragments with independent cache policies.
ESI tags are embedded in HTML and processed by an ESI processor on the edge server. Common directives include <esi:include> to fetch a fragment, <esi:choose> for conditional logic, and <esi:try> for fallback handling. This architecture decouples content delivery from content generation, drastically reducing origin server load and improving time-to-first-byte (TTFB) for complex, personalized web applications.
Key Features of ESI
Edge-Side Includes (ESI) is a simple markup language that enables dynamic content assembly at the CDN edge. It instructs edge servers to compose a single page from multiple fragments, each with its own independent cache policy.
Fragment Assembly
The core mechanism of ESI is the ability to decompose a web page into discrete, cacheable fragments. An ESI processor on the edge server parses the base template and fetches each referenced fragment, assembling the final HTML response on the fly. This allows a page with a Time-To-Live (TTL) of 24 hours to include a personalized shopping cart with a TTL of 0 seconds.
- esi:include tag fetches content from a defined source URL
- esi:inline tag allows content to be embedded directly within the markup
- Fragments can be recursively nested, enabling complex assembly logic
Exception Handling & Fallbacks
ESI provides robust fault tolerance through built-in exception handling. If a fragment's origin server is unavailable or times out, the edge server can serve a stale-while-revalidate version or a predefined fallback resource, preventing a single backend failure from breaking the entire page.
- esi:try block defines a primary fragment request
- esi:attempt specifies alternative fallback sources
- esi:except handles the final failure state gracefully
- Default timeout behavior can be configured per fragment
Conditional Inclusion Logic
ESI supports basic conditional logic based on HTTP request headers, enabling context-aware assembly without hitting the origin server. An edge server can include different fragments based on a user's device type, geolocation, or authentication state by evaluating variables in the incoming request.
- esi:choose acts as a switch statement
- esi:when tests a condition against a header or variable
- esi:otherwise provides a default branch
- Common use case: serving a mobile header fragment vs. a desktop header fragment based on the User-Agent header
Variable Substitution
ESI allows dynamic string substitution within fragments using variables derived from HTTP headers or explicitly set by the edge server. This enables personalization at the edge without requiring a unique fragment for every user. A single cached fragment can display a user's name or a session-specific token.
- $(HTTP_HEADER{name}) syntax reads request headers
- $(ESI_VARIABLE{name}) references server-defined variables
- Commonly used to inject CSRF tokens or user greetings into otherwise static, highly cacheable HTML chunks
Cache Policy Granularity
The primary architectural benefit of ESI is the ability to assign independent cache policies to each fragment. A news article body can be cached for hours, while a "Top Stories" sidebar is cached for minutes, and a user-specific "Continue Reading" bar is never cached. This maximizes cache hit ratios while preserving dynamism.
- Fragment TTLs are controlled by standard HTTP Cache-Control headers from the fragment's origin
- Enables a hole-punching strategy for highly dynamic content within static templates
- Dramatically reduces origin server load by caching the page shell and recomposing only the volatile pieces
Surrogate Key Invalidation
ESI integrates with surrogate key (or cache tag) systems for precise cache invalidation. When a piece of content changes in the CMS, a single API call can purge all fragments associated with that content's unique key across the entire CDN, without needing to track every URL where it appears.
- A product description fragment can be tagged with a key like
prod-12345 - When the product's price updates, a purge request for
prod-12345instantly invalidates all cached instances - Eliminates the need for full cache flushes or complex URL-based purging patterns
Frequently Asked Questions
Clear, technically precise answers to the most common questions about the Edge-Side Includes (ESI) markup language and its role in dynamic content assembly at the CDN edge.
Edge-Side Includes (ESI) is a markup language and edge-processing specification that enables dynamic web page assembly directly on a Content Delivery Network (CDN) edge server. It works by allowing an origin server to deliver a page template containing simple XML-based tags, such as <esi:include>, which instruct the edge server to fetch and stitch together content fragments from different sources. Each fragment can have its own independent caching policy, meaning a highly dynamic shopping cart can be assembled alongside a statically cached product description. The edge server parses the template, resolves all includes, and delivers the fully composed HTML to the client, dramatically reducing origin server load and perceived latency.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Edge-Side Includes (ESI) is a foundational technology within a broader ecosystem of dynamic content assembly. These related concepts define the architectural patterns, caching strategies, and rendering techniques that enable modern, high-performance web experiences.
Surrogate Key
A unique identifier assigned to a piece of content, used to group and purge related cached objects across a CDN without needing to know their individual URLs. This is the primary mechanism for targeted cache invalidation in ESI architectures.
- Enables purging a product description from every page it appears on with a single API call.
- Replaces URL-based purging, which is impractical for highly dynamic, assembled pages.
- Often implemented via response headers like
Surrogate-Key.
Cache Invalidation
The process of purging or updating outdated data from a cache when the source content changes, ensuring users receive the most current version of a resource. In an ESI context, this is granular and fragment-specific.
- A single database update can trigger the invalidation of only the affected ESI fragment.
- Prevents the need to flush entire pages, preserving cache hit ratios.
- Relies on surrogate keys or cache tags for precision targeting.
View Composition
A server-side or edge-side pattern where a final user interface is assembled by aggregating rendered fragments from multiple, independent microservices or templates. ESI is a specific implementation of this broader architectural concept.
- Each fragment can be owned by a different team and deployed independently.
- The assembly layer stitches fragments together based on a page template.
- Contrasts with client-side composition, where assembly happens in the browser via JavaScript.
Content Delivery Network (CDN)
A geographically distributed network of proxy servers that caches content close to end-users, drastically reducing latency and origin server load. ESI is a native feature of many enterprise CDNs like Akamai, Fastly, and Varnish.
- Processes ESI tags at edge nodes before delivering the assembled page to the client.
- Reduces the distance data travels, improving Time to First Byte (TTFB).
- Provides the distributed compute power necessary for fragment-level assembly at scale.
Edge Compute
A distributed computing paradigm that runs application logic and processes data on servers located at the network edge, near the user. ESI processing is a classic edge compute workload.
- Moves assembly logic from a central origin server to globally distributed points of presence.
- Enables personalization logic to execute close to the user without a round-trip to the origin.
- Platforms like Cloudflare Workers and Fastly Compute@Edge offer programmable environments for custom assembly logic beyond basic ESI.
Server-Side Rendering (SSR)
A technique where a web page's HTML is generated on the server for each request. ESI can be used to optimize SSR performance by caching static fragments while still rendering dynamic parts on the server.
- Reduces the load on the SSR infrastructure by offloading cacheable components to the edge.
- Allows a hybrid model where the page shell is statically generated (SSG) and dynamic widgets are included via ESI.
- Improves Time to First Byte (TTFB) for personalized pages by assembling cached and fresh content in parallel.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us