BASH: Fast Purge via CCU v3 API

Document created by Luca Genasci on Aug 7, 2017Last modified by Luca Genasci on Feb 6, 2018
Version 5Show Document
  • View in full screen mode

Updated 06.02.2018:

- new version 0.5: I removed the associative arrays in the script for have the compatibility of bash version 3.x.
- In the User-Agent I added the version of the script.

Updated 26.01.2018:

- new version 0.4 of script. It's work too if the jq tool is not installed: in this case a INFO message displayed.
Updated 25.01.2018: 
- new version 0.3 of script. I have fix the issue with the array compatibility in bash.
  I have tested with bash version
4.1.2(2), 4.3.48(1), 4.4.12(3)

Updated 12.12.2017:
 - new version 0.2 of script. Now it works correctly with cpcode and without domain option.




In collaboration with Marco De March of Akamai Italy I created a simple bash script for fast purging the Akamai cache.

You will find the files attached and run the script:


$> ./ --help

To display options:

usage: [OPTIONS] -o <obj1[,obj2,obj3,...]>

Purge the Akamai cache via CCU REST API v3.

  Please create a config file in ~/.akarc or /etc/.akarc

    -o | --objects        List of objects to purge (with comma separated values)

    -t | --type           Type of objects
                            Possible values: url, cpcode or tag
                            Default: url

    -d | --domain         Domain site (es.
                          To use with type=url

    -a | --action         The desired action to manage the cache
                            Possible values: invalidate or delete
                            Default: invalidate

    -n | --network        The network on which you want to invalidate or delete content
                            Possible values: staging or production
                            Default: production

    -h | --help           Show this message
    -v | --version        Show version


  In the config file the following values have to been declared:
    client_secret = <your client secret>
    client_token = <your client token>
    access_token = <your access token>
    host = <your akamai host>

  There is the possibility to set the default values:
    network = <staging | production>
    action  = <invalidate | delete>
    type    = <url | cpcode | tag>

  If no values are declared the default ones are:
    network = staging
    action  = invalidate
    type    = url


I hope that this script helps someone.


Best Regards.