Expand my Community achievements bar.

SOLVED

How to call flush agent programmatically for flushing referenced page

Avatar

Level 4

Hi All,

As part of flushing referenced pages, we have to call flush agent programmatically to flush each referenced page for scaffolding content.

Scaffolding content is added in different pages and cache invalidation has to be happen for all referenced pages whenever scaffolding content page has to replicated from author to publish.

I tried the below API to call flush agent similar to calling normal replication agent for publishing content from author to publish. It is invoking flush agent.

ReplicationOptions opts = new ReplicationOptions();

          opts.setSuppressVersions(true);

          opts.setSuppressStatusUpdate(true);

          AgentIdFilter agentIdFilter = new AgentIdFilter("flush");

          opts.setFilter(agentIdFilter);

  replicator.replicate(session, ReplicationActionType.ACTIVATE, action.getPath(), opts);

Not sure whether it is proper way to do it ? Is there any other way to call flush agent programmatically ?

I don't want to flush each page by using CURL or PostMethod method call.

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

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

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

1 Accepted Solution

Avatar

Correct answer by
Level 10

If the paths to be flushed are already known, there is another configuration based approach for flushing cache using ACS Commons Dispatcher Flush Rules​. This could be a better option than deploying code/bundle for flushing cache, otherwise you could extend this API to build a custom solution.

Alternatively, you could build a custom configuration-based solution via shell scripts/apache modules based on complexities involved in use case considering all other aspects.

View solution in original post

3 Replies

Avatar

Correct answer by
Level 10

If the paths to be flushed are already known, there is another configuration based approach for flushing cache using ACS Commons Dispatcher Flush Rules​. This could be a better option than deploying code/bundle for flushing cache, otherwise you could extend this API to build a custom solution.

Alternatively, you could build a custom configuration-based solution via shell scripts/apache modules based on complexities involved in use case considering all other aspects.

Avatar

Level 4

Hi Gaurav. Thanks for your inputs. I want to know how to invoke flush agents from Java similar like normal replication agents.