← Back to list

Mastering Sling Dynamic Include (SDI) in AEM: Boost Performance Without Losing Dynamic Content

In Adobe Experience Manager (AEM), many pages are predominantly static, making caching mechanisms like dispatchers highly effective…

Gururaj Koni · 2025-01-10 13:06 · 50 claps · 2.6 min read paywalled
#aem #performance #sling-dynamic-include #aem-developer #aem-architect
Open on Medium ↗
Wiki topics: 🏛️ · Architecture

Mastering Sling Dynamic Include (SDI) in AEM: Boost Performance Without Losing Dynamic Content

In Adobe Experience Manager (AEM), many pages are predominantly static, making caching mechanisms like dispatchers highly effective. However, challenges arise when certain page components need to display dynamic content.

Non-members can access it here.

For instance, a news website’s homepage might require displaying region-specific headlines, but caching could cause the same news to appear across all regions.

To address such scenarios, AEM offers the Sling Dynamic Include (SDI) feature, which facilitates the dynamic inclusion of specific page elements.

Step 1 : Integrating Sling Dynamic Include with AEM 6.5

I won’t be covering the installation process for Sling Dynamic Include — as it is already well-documented in references [4] and [5].

Step 2: Configure Components for Dynamic Inclusion

After installing the SDI bundle, configure the desired components for dynamic inclusion by creating an OSGi configuration with the following parameters:

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
          xmlns:cq="http://www.day.com/jcr/cq/1.0"
          xmlns:jcr="http://www.jcp.org/jcr/1.0"
          xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
          jcr:primaryType="sling:OsgiConfig"
          include-filter.config.enabled="{Boolean}true"
          include-filter.config.path="/content"
          include-filter.config.resource-types="[my-app/components/content/dynamic_included_component]"
          include-filter.config.include-type="SSI"
          include-filter.config.add_comment="{Boolean}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="{Boolean}true"/>

Parameter Descriptions:

  • enabled: Set to true to activate SDI.
  • path: Specifies the content path where SDI is applicable.
  • resource-types: Lists the components to be dynamically included.
  • include-type: Determines the inclusion method:
  • Apache SSI: Server Side Includes processed by the Apache HTTP Server.
  • ESI: Edge Side Includes, evaluated by a Content Delivery Network (CDN).
  • JavaScript: Uses AJAX to load components in the browser.
  • add_comment: If true, adds a debug comment to each replaced component.
  • selector: Selector added to HTTP requests to fetch the actual content.
  • ttl: Time-to-live in seconds for the rendered component; applicable for Dispatcher version 4.1.11 and above.
  • required_header: SDI activates only if this header is present in the request. By default, it’s Server-Agent=Communique-Dispatcher.
  • ignoreUrlParams: Lists URL parameters that SDI should ignore, allowing it to process requests with specific GET parameters.
  • rewrite: Enables rewriting links according to Sling mappings for dynamic content inclusion.

Step 3: Update Dispatcher Configurations

  1. Enable the mod_include module in the Apache HTTP Server's httpd.conf file:
LoadModule include_module modules/mod_include.so
  1. Modify the virtual host configuration:

In the dispatcher.conf file, adjust the <IfModule> section:

<IfModule dispatcher_module>
    SetHandler dispatcher-handler
</IfModule>
SetOutputFilter INCLUDES

Add Includes to the Options directive within the <VirtualHost> block:

<VirtualHost *:80>
    ...
    <Directory />
        ...
        Options FollowSymLinks Includes
        AllowOverride None
        ...
    </Directory>
    ...
</VirtualHost>

3. Specify file types for the INCLUDES filter in the httpd.conf file:

<Directory /mnt/var/www/html>
    ...
    Options Indexes FollowSymLinks Includes
    ...
    AddOutputFilter INCLUDES .html
    AddOutputFilterByType INCLUDES text/plain text/html
    ...
</Directory>

4. Update caching rules in rules.any or dispatcher.any to exclude dynamic content from caching:

/0008 {
    /glob "*.nocache.html*"
    /type "deny"
}

Ensure the selector (nocache) matches the one defined in the OSGi configuration (include-filter.config.selector).

5. Restart the Apache server to apply the changes:

sudo apachectl restart
# or
sudo service httpd restart

Verification

To confirm that SDI is functioning correctly:

  1. View the page source of the webpage containing the dynamically included component.
  2. Search for SDI include tags in the source code. Configured components should be replaced with SDI tags, indicating successful dynamic inclusion.

By implementing Sling Dynamic Include, you can effectively manage dynamic content within cached pages in AEM, ensuring that users receive personalized and up-to-date information without compromising caching efficiency.

References

[1] AEM Dispatcher — Create the Perfect Caching Architecture

[2] Dispatcher Concepts, Patterns and Antipatterns

[3] Apache Sling Dynamic Include

[4] Experience League: Set up Sling Dynamic Include

[5] AEM Sling Dynamic include by Imran Khan


메타데이터
post_id
c7c2fc77f15f
slug
mastering-sling-dynamic-include-sdi-in-aem-boost-performance-without-losing-dynamic-content-c7c2fc77f15f
url
https://medium.com/@gururajkoni/mastering-sling-dynamic-include-sdi-in-aem-boost-performance-without-losing-dynamic-content-c7c2fc77f15f
canonical_url
https://medium.com/@gururajkoni/mastering-sling-dynamic-include-sdi-in-aem-boost-performance-without-losing-dynamic-content-c7c2fc77f15f
author_url
https://medium.com/@gururajkoni
status
ok
fetched_at
2026-06-27 18:20:27