March 28, 2020
Estimated Post Reading Time ~

AEM Sling Dynamic Include

Sling Dynamic Include (SDI) is an OSGi service that enables us to automatically replace configured components with the include tags.

Firstly download and install the Sling Dynamic Include bundle from the link in AEM bundles console.

Configure the SDI configuration in Felix console like in the below screenshot.

Enter the list of components (specify their resourceTypes) in configuration & update include tag type (SSI, ESI, or AJAX) so that SDI will do the rest.


After this, AEM Page will not show the component on UI but was included as part of the SDI configuration can see in view source of the page.

For Component to be visible on front-end UI do following in httpd.conf file

1> Un-Comment below the line - which includes all files.
LoadModule include_module libexec/apache2/mod_include.so

2> Update the vhost file to respect include directives, add bolded & underlined text below

<VirtualHost *:80>
<Directory /Library/WebServer/docroot/publish>
...
# Add Includes enabling SSI Includes used by Slind Dynamic Include
Options FollowSymLinks Includes

# Set includes to process .html files
AddOutputFilter INCLUDES .html

...

</Directory>
</VirtualHost>

Now Component can be seen but Wait here it won't be updating content dynamically. It is served from cache content.

Now we need to tell the dispatcher that nocache selector which is the name we defined in SDI configuration needs NOT to be Cached.

/cache {
/glob "*.nocache.html*"
/type "deny"
/enableTTL "1"
}

Now Restart Apache Web Server after making changes to HTTPD configuration files or the dispatcher.any.

Now AEM Components whose resource types are mentioned in AEM SDI configuration will not be cached it always serves dynamic content, not from cache.


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.