简体   繁体   中英

Akamai clear cache after publishing

I'm publishing data from php code to Akamai CDN. I'm looking for a way to clear cache of my data after publish is completed. Can I do it from Akamai user interface? Or should I implement it in my php app?

I think you will have to provide more details here.

1) If you have a 1st level of caching in your server for example a webserver then akamai will understand that there is a change in content and refresh its content automatically once the ttl is expired.

2) If you have set TTL to a high number and want the application to inform akamai about the content update then you can implement this using akamai API's.

3) You this is a not a recurring activity then you can login to Luna portal, navigate to "Publish-> Content Control Utility" and do the cache clear as per your need. It usually takes 30 to 40min for cache removal.

Hope it helps. :)

You can use Luna as Vinod mentioned, but it is a tedius manual process.

Your best bet here is to use the Akamai {OPEN} APIs, integrated into your PHP script. I've got a blog post covering this use case at:

https://community.akamai.com/community/developer/blog/2015/08/19/getting-started-with-the-v2-open-ccu-api

There is PHP sample code in the github repository here:

https://www.github.com/akamai-open/api-kickstart

Under examples/php

Kirsten

After few hours of researching and after that I got login credentials to ACCU. This is the snippet that made purge working for me:

    $data = array("type" => "arl", "action" => "invalidate", "objects" => array($file));
    $data_string = json_encode($data);
    $ch = curl_init('https://api.ccu.akamai.com/ccu/v2/queues/default');
    curl_setopt($ch, CURLOPT_USERPWD, "aaa:bbb");
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));

    // Send the request & save response to $resp
    $resp = curl_exec($ch);
    // Close request to clear up some resources
    curl_close($ch);

Thanks all for the help and the guidance

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM