Skip to content

Sling Dynamic Include vs Edge Side Includes (ESI) in AEM as a Cloud Service

How Sling Dynamic Include works in AEM, its OSGi config and SSI, ESI and JSI modes, ESI on Adobe's managed CDN, the Dispatcher setup, and which to use when.

Written in November 2026 for AEM as a Cloud Service and AEM 6.5. Checked against the Apache Sling Dynamic Include source and README, Adobe's Edge Side Includes and Dispatcher documentation, and Adobe's Sling Dynamic Include tutorial.

On this page
  1. What does Sling Dynamic Include do?
  2. How do you install and configure SDI?
  3. How do you set up SSI in the Dispatcher?
  4. How do you use ESI on Adobe's CDN?
  5. SSI, ESI or JSI: which should you use?

Sling Dynamic Include (SDI) is an Apache Sling bundle that lets a page be cached while a few of its components stay fresh. For the component types you configure, it replaces their rendered HTML with an include tag pointing back at the component, and something downstream fills the tag in on every request: Apache at the Dispatcher for an SSI tag, the CDN for an ESI tag, or the browser for a JavaScript include. Edge Side Includes (ESI) is therefore not a rival to SDI but one of its output formats. On AEM as a Cloud Service, Adobe's managed CDN now supports ESI, and SSI works at the Dispatcher, so both routes are open.

What does Sling Dynamic Include do?

SDI is a Sling filter on included requests, the ones a page makes when it renders a child component through data-sly-resource or a JSP include. When the included resource has one of the configured resource types, the filter writes a tag instead of the component's markup. The URL in the tag is the component's own path with an extra selector, nocache by default:

<!-- in the page as AEM renders it -->
<div class="header">
  <sly data-sly-resource="${'userinfo' @ resourceType='wknd/components/userinfo'}"/>
</div>

<!-- what SDI writes in its place, include type SSI -->
<!--#include virtual="/content/wknd/us/en/jcr:content/userinfo.nocache.html" -->

<!-- include type ESI -->
<esi:include src="/content/wknd/us/en/jcr:content/userinfo.nocache.html"/>

When the request for userinfo.nocache.html comes back, the filter sees the selector and lets the component render normally. A component with no node behind it (a synthetic resource) gets its resource type appended as a suffix, userinfo.nocache.html/wknd/components/userinfo, so SDI can rebuild it. The third mode, JSI, writes a div with a short XMLHttpRequest script that loads the same URL in the browser.

The project README names what SDI can't handle: components that process POST requests or GET parameters, and synthetic components that already use a suffix. By default it skips requests with query parameters, and requests without the Dispatcher's Server-Agent: Communique-Dispatcher header. On author, or when you call publish directly, pages render as if SDI weren't installed. That's useful for testing and confusing if you don't know it.

How do you install and configure SDI?

SDI isn't part of AEM. Add the dependency, and on AEM as a Cloud Service embed the bundle in your all package like any other third-party bundle:

<dependency>
  <groupId>org.apache.sling</groupId>
  <artifactId>org.apache.sling.dynamic-include</artifactId>
  <version>3.3.2</version>
</dependency>

Version 3.3.2 is the latest release on Maven Central as of November 2026. Configuration is a factory with the PID org.apache.sling.dynamicinclude.Configuration, so you can have several, one per path and set of components. Put it in the publish run mode, for example ui.config/src/main/content/jcr_root/apps/wknd/osgiconfig/config.publish/org.apache.sling.dynamicinclude.Configuration~content.cfg.json:

{
  "include-filter.config.enabled": true,
  "include-filter.config.path": "/content",
  "include-filter.config.resource-types": ["wknd/components/userinfo"],
  "include-filter.config.include-type": "SSI",
  "include-filter.config.add_comment": false,
  "include-filter.config.selector": "nocache",
  "include-filter.config.ttl": "",
  "include-filter.config.required_header": "Server-Agent=Communique-Dispatcher",
  "include-filter.config.ignoreUrlParams": [],
  "include-filter.config.rewrite": true
}

What each property does, with the default from the configuration source:

PropertyDefaultMeaning
enabledfalseSwitches this configuration on.
path/contentPath prefix the configuration applies to; a value starting with ^ is a regular expression.
resource-typesemptyComponent resource types to replace.
include-typeSSISSI, ESI or JSI.
add_commentfalseWrites an HTML comment naming the path and type before each tag. Keep it off for components that don't output HTML.
selectornocacheSelector that marks a fragment request.
ttlemptySeconds of cache lifetime set on the rendered fragment; needs Dispatcher 4.1.11 or later with TTL enabled.
required_headerServer-Agent=Communique-DispatcherSDI acts only when this header is present.
ignoreUrlParamsemptyQuery parameters (Java regex allowed) that don't stop SDI from acting.
rewritefalseMaps the include URL through Sling resource mappings, useful when publish URLs hide /content.
appendSuffixtruePasses the page's suffix on to the include.

Each key in the file carries the prefix include-filter.config.. If editable templates lock the component into initial content, add a second configuration with path set to /conf; Adobe's SDI tutorial does exactly that. With rewrite on, check the generated tags once against your short URL mappings, because the fragment URL has to survive the same rewrites as the page.

How do you set up SSI in the Dispatcher?

For SSI, Apache has to parse the HTML the Dispatcher returns. Adobe's knowledge base states that on AEM as a Cloud Service mod_include is loaded by default and SSI through SDI works, in the SDK and in the cloud. Enable includes in your site's own vhost file, since default.vhost is immutable:

# conf.d/available_vhosts/wknd.vhost (inside the VirtualHost)
<Directory "${DOCROOT}">
    Options FollowSymLinks Includes
    AddOutputFilter INCLUDES .html
    ModMimeUsePathInfo On
</Directory>

Adobe's tutorial uses these three directives; ModMimeUsePathInfo On is what lets the output filter act on content served by the Dispatcher handler. Run ./bin/validate.sh src/dispatcher afterwards, because the cloud Dispatcher accepts only allowlisted directives and the validator tells you if your SDK version rejects one.

Next, keep fragments out of the Dispatcher cache, or the first visitor's version is served to every later visitor. In conf.dispatcher.d/cache/rules.any:

$include "./default_rules.any"

# never cache SDI fragments
/0100 { /glob "*.nocache.html*" /type "deny" }

Keep the trailing * so fragments with a suffix match too. If a fragment may be a few seconds old, drop that rule, set ttl in the SDI configuration, and rely on /enableTTL "1", which the archetype's farm already sets. Fragment URLs end in .html under /content, so the default Dispatcher filter rules let them through; a custom extension or a path outside /content needs its own allow rule.

How do you use ESI on Adobe's CDN?

Switch the SDI configuration to "include-filter.config.include-type": "ESI", then tell the CDN which pages to process. Adobe's ESI page lists three settings, all in the Apache configuration:

<LocationMatch "^/content/wknd/.*\.html$">
    # send the page to the CDN uncompressed so it can read the ESI tags
    SetEnv no-gzip 1
    # ask the CDN to evaluate ESI tags in this response
    Header set x-aem-esi "on"
    # let the CDN compress the assembled page for the browser
    Header set x-aem-compress "on"
    Header always set Cache-Control "max-age=300"
</LocationMatch>
<LocationMatch "\.nocache\.html">
    SetEnv no-gzip 1
    Header always set Cache-Control "no-cache"
</LocationMatch>

The CDN supports the ESI include, comment and remove tags. It processes includes one after another rather than in parallel, it goes at most 5 levels deep, and it handles at most 256 fragments per page. Every fragment marked no-cache is a trip to the origin on each page view, so a page with ten of them waits for ten requests in a row.

Older advice says the opposite: an Adobe knowledge base article still says ESI isn't supported on the out-of-the-box Fastly CDN. Adobe's dedicated ESI page is newer and describes the feature as supported for sites rendered with AEM publishing, so follow that page and test on a development environment first. On AEM 6.5 behind your own CDN, ESI depends on that CDN; the SDI README shows the switch for Varnish.

SSI, ESI or JSI: which should you use?

The deciding question is where the page gets assembled, because that's the last layer that can cache the parent page for long.

ModeAssembled byParent page can be cached atUse it when
SSIApache at the Dispatcherthe Dispatcher; the CDN only brieflythe site has no ESI-capable CDN in front of it and the fragment is cheap to render
ESIthe CDNthe CDN, with a long TTLyou're on AEM as a Cloud Service and want the parent page cached at the edge while one block refreshes often
JSIthe browsereverywherethe content is per visitor, can appear after the page loads, and doesn't need to be indexed by search engines

The SSI row hides a trap. Apache fills in the fragment before the response leaves the Dispatcher, so the CDN receives a finished page. Cache that page at the CDN for an hour and the "live" fragment is an hour old. With SSI, give the parent page a short CDN lifetime, or accept that the fragment refreshes only as often as the CDN copy does.

For data that is the same for every visitor but changes every few minutes, such as a news list or stock prices, ESI with a short max-age on the fragment means the origin renders only that fragment, a few times an hour. For data that differs per visitor, such as a name or a cart count, the fragment must not be cached anywhere shared. JSI then wins on simplicity.

More in Architecture and platform