How to manage dispatcher cache invalidations with a reference type component | Community
Skip to main content
sutty1000
New Participant
December 21, 2016
Solved

How to manage dispatcher cache invalidations with a reference type component

  • December 21, 2016
  • 1 reply
  • 1627 views

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Runal_Trivedi

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

 

1 reply

Runal_Trivedi
Runal_TrivediAccepted solution
New Participant
January 2, 2017

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