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.
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.
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.
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.