Akamai’s cdn is great for offloading pages on to their edge server network. We were having issues when a content admin would update content that it would take a while for the changes to propagate out. Here is a custom Drupal module and WordPress Plugin using php to purge the Akamai cache after a page has been changed. It was also easy for us to update this module when we added Varnish in to our caching stack.

Basic setup Drupal

Our Drupal module will have an admin page that allows the user to purge a specific url. This comes in handy if their is a image that is stale or if a page has query parameters that need to be purged.

The node update hook is provided by the expires module. The module also allows you to specify additional pages that need to get updated like the site’s front page or the category page that contains the new content. If you do not want to install this module then you can just use the standard node save hook and look for not is new.

Here is how to setup the expires module to external caching.

Module Folder:


The Akamai rest api uses a JSON post request and responds back with a json response. We will parse the response to let our admin users know that the purge request was sent and how long it will take to be completed.


Adding on Varnish was pretty easy. Here is the method for purging a pool of Varnish servers using the BAN method.


Now for the WordPress Plugin

WordPress provides a very simple hook for when content is updated.  Here is a custom wordpress plugin to purge akamai for the updated page and the site’s homepage.
Plugin file structure:


Like the Drupal module it sends a purge to Akamai and Varnish for the updated content.  We have had this code in production for the past few months and have not had any issues.
As we are deploying our first node.js and express apps I have been porting this code over to Javascript.  Node’s request library is a perfect replacement for curl.
Cache all the things!