Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Can we integrate CloudFront Cache clearance with Workflow

Avatar

Level 3

In our environment, authors will publish several times on specific pages like test1, test2, and test3 during day time. To validate those changes in site1.com, they have to wait for one hour to clear the cache as per our Current TTL time.

 So, We want to integrate this clear cache process in the workflow, so we don't need to rely on TTL time.

 

Is it possible for us to clear the cache of each path in Cloud Front instead of the entire project, and Is it possible to connect the Cloud Front console from the code?

 

If we have access to the CloudFront from the code, we can take the payload from the workflow, append site1.com( for prod) and send the complete URL to the console to clear the cache.

 

Ex: payload - /content/site1/test

if it is prod we will append site1.com to it - https://www.site1.com/test

stage - https://uat.site1.com/test

 

Note: I know we have to clear the dispatcher's cache before clearing the cache in CDN. I am thinking about exploring a replication agent(dispatcher-flush) in the author to invalidate the cache.

 

Please advise if you have any thoughts/suggestions on this process.

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @ramaem12,

There are three possibilities here:

  1. Set up a flush agent on Author: Use 'CloudFront' Invalidate Rest API to trigger cache clear only for those paths which are flushed from author instance.
    Issue: There will always be a race condition between Author -> CDN and Author -> Publisher -> Dispatcher -> CDN.
    If the latter (Author -> Publisher -> Dispatcher -> CDN) is executed first and then Author -> CDN, you will not see an issue but if Author -> CDN is triggered first then the copy of the file is deleted from the CDN's edge locations and co-incidentally during that time if a user requests for a new copy of the file then the old copy will be served from the origin (dispatcher) because the Author -> Publisher -> Dispatcher -> CDN series of events are not yet completed.
  2. Set up a flush agent on Publisher: Use 'CloudFront' Invalidate Rest API to trigger cache clear only for those paths which are flushed from publish instance.
    Issue: If you have multiple publish instances set-up then from each instance a call to CDN is made which can be unnecessary. Also, another race condition here as well can occur as we saw in above possibility.
  3. Set up a Custom Workflow to programmatically control the series of actions:
    a. On replicating a page on Author, a workflow will be triggered. (The replication queue will be ignored by default).
    b. The content of the page will then be replicated programmatically using the replication agents set up.
    c. Flush the dispatcher agent.
    d. Trigger CDN invalidate request.
    Issue: If any of your publisher is down, entire workflow can be stuck.


Based on the above three possibilities it is always better to lower the TTL value of your CDN.

The above solution is also discussed in the post here: https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/can-we-control-the-order-o...

Hope this helps!

Jineet

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

Hi @ramaem12,

There are three possibilities here:

  1. Set up a flush agent on Author: Use 'CloudFront' Invalidate Rest API to trigger cache clear only for those paths which are flushed from author instance.
    Issue: There will always be a race condition between Author -> CDN and Author -> Publisher -> Dispatcher -> CDN.
    If the latter (Author -> Publisher -> Dispatcher -> CDN) is executed first and then Author -> CDN, you will not see an issue but if Author -> CDN is triggered first then the copy of the file is deleted from the CDN's edge locations and co-incidentally during that time if a user requests for a new copy of the file then the old copy will be served from the origin (dispatcher) because the Author -> Publisher -> Dispatcher -> CDN series of events are not yet completed.
  2. Set up a flush agent on Publisher: Use 'CloudFront' Invalidate Rest API to trigger cache clear only for those paths which are flushed from publish instance.
    Issue: If you have multiple publish instances set-up then from each instance a call to CDN is made which can be unnecessary. Also, another race condition here as well can occur as we saw in above possibility.
  3. Set up a Custom Workflow to programmatically control the series of actions:
    a. On replicating a page on Author, a workflow will be triggered. (The replication queue will be ignored by default).
    b. The content of the page will then be replicated programmatically using the replication agents set up.
    c. Flush the dispatcher agent.
    d. Trigger CDN invalidate request.
    Issue: If any of your publisher is down, entire workflow can be stuck.


Based on the above three possibilities it is always better to lower the TTL value of your CDN.

The above solution is also discussed in the post here: https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/can-we-control-the-order-o...

Hope this helps!

Jineet

Avatar

Community Advisor

@Jineet_Vora As mentioned by Jineet, we can three ways to implement and i would prefer to have "Cloudfront Flush Agent" in AEM Publishers to the Job.