AEM Sling Dynamic Include

   
    Sling Dynamic Include (SDI) is an OSGi service that enables 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 below screenshot.

Enter 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 SDI configuration can see in view source of page.

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

1> Un-Comment below 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 to enable 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 wont be updating content dyamically. It is served from cache content. 

Now we need to tell dispatcher that nocache selector which is the name we defined in SDI configuration need 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 serve dynamic content not from cache.