Content is not properly displaying on dispatcher URL | Community
Skip to main content
Level 2
March 24, 2025
Solved

Content is not properly displaying on dispatcher URL

  • March 24, 2025
  • 3 replies
  • 543 views

Hi Team,

I have a requirement where we have timer on page, we have to display the content1 (div1) during the timer running and on completion of timer, the page should refresh and display the different content (div 2).

This is working fine on author but on runway page the content is not changing after refresh. I know it is happening because of caching (after adding query parameters on URL it's working fine). Is there a way to fix this issue? 

Best answer by arunpatidar

Hi @naveent1 

There are two possible solutions to address this issue:

  1. Client-Side Javascript: Use JavaScript to dynamically show or hide content. You can expose the time via a meta tag or make an HEAD request to the component/page to fetch the current time.

  2. Sling Dynamic Include (SDI): Implement SDI for the component and disable caching to ensure real-time updates. More details can be found here: Sling Dynamic Include.

3 replies

arunpatidar
Community Advisor
arunpatidarCommunity AdvisorAccepted solution
Community Advisor
March 24, 2025

Hi @naveent1 

There are two possible solutions to address this issue:

  1. Client-Side Javascript: Use JavaScript to dynamically show or hide content. You can expose the time via a meta tag or make an HEAD request to the component/page to fetch the current time.

  2. Sling Dynamic Include (SDI): Implement SDI for the component and disable caching to ensure real-time updates. More details can be found here: Sling Dynamic Include.

Arun Patidar
narendiran_ravi
Level 6
March 24, 2025

Hi @naveent1 ,

Instead of refreshing the page, consider using AJAX calls to fetch updated content and replace the current content without a full page reload. This ensures that the latest content is fetched directly from the server.

AmitVishwakarma
Community Advisor
Community Advisor
March 24, 2025

Hi @naveent1 ,

Root Cause:

     - Dispatcher caches the page (HTML output) and serves it again on refresh.

     - So even after the timer completes and the page reloads, the same cached content (with div1) is served.

 

There are two possible solutions to address this issue:

 

Option 1: Sling Dynamic Include (SDI) – Production Ready Fix

 

How it Works:

     - SDI allows parts of the page (components) to be dynamically included via AJAX.

     - Dispatcher caches the page shell, but your component (div1/div2) is fetched fresh from the server.

Steps:

     - Install SDI in AEM if not already: Add Sling Dynamic Include bundle.

     - In your component's HTL, wrap div1/div2 logic:

<!-- Example --> <sling:include path="/content/your-page/jcr:content/div-component" resourceType="your/components/div" />

     - In the dispatcher config, set up to not cache .shtml files (used by SDI).

     - Configure SDI in AEM:

          - Go to /system/console/configMgr → Find SDI Configuration

          - Enable for your component/resourceType

          - Set include type = SSI or ESI based on your setup.

     - Dispatcher Config Update:

# Never cache shtml files (used for SDI) <FilesMatch "\.shtml$"> Header set Cache-Control "no-cache, no-store, must-revalidate" </FilesMatch>