{"id":3775,"date":"2014-06-23T06:27:56","date_gmt":"2014-06-23T11:27:56","guid":{"rendered":"http:\/\/appcrawler.com\/wordpress\/?p=3775"},"modified":"2014-06-24T15:13:23","modified_gmt":"2014-06-24T20:13:23","slug":"purging-akamai-cache","status":"publish","type":"post","link":"http:\/\/appcrawler.com\/wordpress\/2014\/06\/23\/purging-akamai-cache\/","title":{"rendered":"Purging Akamai cache"},"content":{"rendered":"<p>To purge content from the cache on the Akamai edge servers, you can use the main LUNA control center, which will push the request out to the edge servers affected.  As such, keep in mind the cache is not immediately purged.<\/p>\n<p>EdgeControl management center is deprecated.  Instead, navigate to publishing\/content control utility in LUNA. <\/p>\n<p><img decoding=\"async\" src=\"http:\/\/appcrawler.com\/wordpress\/wp-content\/uploads\/2014\/06\/130.png\"><\/p>\n<p>Enter the appropriate URL\/ARL (Akamai Resource Locator)<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/appcrawler.com\/wordpress\/wp-content\/uploads\/2014\/06\/964.png\"><\/p>\n<p>You can also do CP codes.  We only regularly invalidate the home page and category pages, not the entire catalog.  This is because the home page and top level category pages have a TTL of 1 day.  Catalog is only 45 minutes, so we simply wait for it to age off.<\/p>\n<p>You can also make a RESTful web service call via http, using whatever client you use.  You supply a JSON object with the list or ARL\/URL&#8217;s or the cpcodes, and submit with authentication credentials to the URL.<\/p>\n<p>A python implementation is below.  This will submit the purge request, then query the status URI returned by the request to provide feedback on the progress.<\/p>\n<pre lang=\"python\">\r\nimport urllib2, base64, json, time, sys\r\n\r\nif len(sys.argv) != 2:\r\n  print \"Please provide a comma separated list of cpcodes to purge\"\r\n  sys.exit(1)\r\nelse:\r\n  headers = {\"Content-type\": \"application\/json\", \"Accept\": \"text\/plain\"}\r\n  data = {\"type\":\"cpcode\",\"action\":\"invalidate\",\"domain\":\"staging\",\"objects\":sys.argv[1].split(\",\")}\r\n  req = urllib2.Request(\"https:\/\/api.ccu.akamai.com\/ccu\/v2\/queues\/default\",json.dumps(data),headers)\r\n  base64string = base64.encodestring('%s:%s' % (\"your_name@your_email_domain.com\",\"your_password\")).replace('\\n', '')\r\n  req.add_header(\"Authorization\", \"Basic %s\" % base64string) \r\n  resp = urllib2.urlopen(req).read()\r\n  tmp = eval(resp)\r\n  print tmp\r\n  prog = tmp[\"progressUri\"]\r\n\r\n  print \"progressUri = https:\/\/api.ccu.akamai.com\" + prog + \"\\n\"\r\n  print \"sleeping \" + str(tmp[\"pingAfterSeconds\"]) + \" seconds until issuing the first check...\"\r\n  time.sleep(int(tmp[\"pingAfterSeconds\"]) + 10)\r\n\r\n  while True:\r\n    req2 = urllib2.Request(\"https:\/\/api.ccu.akamai.com\" + prog)\r\n    req2.add_header(\"Authorization\", \"Basic %s\" % base64string) \r\n    tmp = urllib2.urlopen(req2).read()\r\n    status = eval(tmp.replace(\"null\",\"None\"))\r\n    if status[\"purgeStatus\"] == \"Done\":\r\n      print \"purge complete\"\r\n      sys.exit(0)\r\n    else:\r\n      print time.ctime() + '\\tpurge still running...'\r\n      time.sleep(30)\r\n<\/pre>\n<p>You will see output such as that below&#8230;<\/p>\n<pre>\r\nc:\\>Python27\\python.exe purge.py your CPcode\r\nprogressUri = https:\/\/api.ccu.akamai.com\/ccu\/v2\/purges\/ec98d52a-eb4f-11e3-a245-64002db3af9e\r\n\r\nMon Jun 09 10:27:59 2014        purge still running...\r\nMon Jun 09 10:28:30 2014        purge still running...\r\nMon Jun 09 10:29:01 2014        purge still running...\r\nMon Jun 09 10:29:31 2014        purge still running...\r\nMon Jun 09 10:30:02 2014        purge still running...\r\nMon Jun 09 10:30:32 2014        purge still running...\r\npurge complete\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>To purge content from the cache on the Akamai edge servers, you can use the main LUNA control center, which will push the request out to the edge servers affected. As such, keep in mind the cache is not immediately&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"http:\/\/appcrawler.com\/wordpress\/2014\/06\/23\/purging-akamai-cache\/\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"footnotes":""},"categories":[50],"tags":[],"_links":{"self":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/3775"}],"collection":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/comments?post=3775"}],"version-history":[{"count":10,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/3775\/revisions"}],"predecessor-version":[{"id":3882,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/3775\/revisions\/3882"}],"wp:attachment":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/media?parent=3775"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/categories?post=3775"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/tags?post=3775"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}