Akamai cache clearing via API
This article explains how to programmatically sync CDN invalidation in Dynamic Media Classic while clearing all child caches of the parent asset in Akamai. It details the configuration of the cache-key and the handling of URLs with different domains, SmartCrops, and parameters behind the question mark.
Description description
Environment
Dynamic Media Classic
Issue/Symptoms
How to sync CDN invalidation in Dynamic Media while simultaneously clearing all child caches of the parent asset in Akamai, and do it programmatically via an API?
Resolution resolution
The cache-key is configured to be the origin vip, and then the URL up to the question mark, or end of the URL in case there is no question mark present.
This means:
-
URLs with the same image but different domains can share the same cache-entry and be invalidated with one CDN invalidate request. For example:
https://company1.scene7.com/is/image/company/image?wid=500
https://company2.scene7.com.com/is/image/company/image?wid=500
-
If you are making use of SmartCrops (this would need AEM Assets), they need to be part of the CDN invalidation request, since the smartcrop’s location in the URL is before the questionmark:
https://company.scene7.com/is/image/company/image:smartcrop
-
If you are making use of parameters behind the question mark, they can be dropped from the CDN invalidation request, as all variations behind question mark are included in the cache invalidation.
For example, invalidating https://company.scene7.com/is/image/company/image would remove the following cache entries from cache:
- https://company.scene7.com/is/image/company/image?wid=500
- https://company.scene7.com/is/image/company/image?wid=400
- https://company.scene7.com/is/image/company/image?qlt=60,1&wid=450&op_sharpen=1
For the API function you would use to invalidate CDN cache, refer to this documentation.