Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

How to manage dispatcher cache invalidations with a reference type component

sutty1000
Level 2
Level 2

We are looking to create/use a reference type component, my question is what process have people used before to manage dispatcher cache invalidation for when the component that has been referenced is updated to ensure that all pages where it has been referenced on are also invalidated on the dispatcher? asking users to republish these pages manually is not really an option for us.

1 Accepted Solution
Runal_Trivedi
Correct answer by
Community Advisor
Community Advisor

if you are using a boilerplate approach to maintain all your content for reference component, then here is what you can do;

  • bind activation event listener to activation of just that boiler plate.

Refer following article for more details around replication listener - https://helpx.adobe.com/experience-manager/kb/ReplicationListener.html

  • find pages that contains reference component pointing to boiler plate content.
  • programmatically issue dispatcher flush for all those pages.

Reference code for programmatically flushing the cache:

            PostMethod post = new PostMethod("http://localhost:80/dispatcher/invalidate.cache");

            post.setRequestHeader("CQ-Action", "Activate");

            post.setRequestHeader("CQ-Handle",handle);

 

            if (StringUtils.isNotBlank(pagePath))

            {

                StringRequestEntity body = new StringRequestEntity(pagePath,null,null);

                post.setRequestEntity(body);

                post.setRequestHeader("Content-length", String.valueOf(body.getContentLength()));

            }

 

Above code does what dispatcher flush agent does, it basically issues programmatic cache-flush request for specific pagePaths

Hope this helps 🙂

- Runal

 

View solution in original post

1 Reply
Runal_Trivedi
Correct answer by
Community Advisor
Community Advisor

if you are using a boilerplate approach to maintain all your content for reference component, then here is what you can do;

  • bind activation event listener to activation of just that boiler plate.

Refer following article for more details around replication listener - https://helpx.adobe.com/experience-manager/kb/ReplicationListener.html

  • find pages that contains reference component pointing to boiler plate content.
  • programmatically issue dispatcher flush for all those pages.

Reference code for programmatically flushing the cache:

            PostMethod post = new PostMethod("http://localhost:80/dispatcher/invalidate.cache");

            post.setRequestHeader("CQ-Action", "Activate");

            post.setRequestHeader("CQ-Handle",handle);

 

            if (StringUtils.isNotBlank(pagePath))

            {

                StringRequestEntity body = new StringRequestEntity(pagePath,null,null);

                post.setRequestEntity(body);

                post.setRequestHeader("Content-length", String.valueOf(body.getContentLength()));

            }

 

Above code does what dispatcher flush agent does, it basically issues programmatic cache-flush request for specific pagePaths

Hope this helps 🙂

- Runal