Purging assets like a boss with the MaxCDN API

MaxCDN has a great purging mechanism in place that offers real time purging. Purging is part of what makes a CDN work properly, as you will want the latest copy of blogposts being served to your users. Not having the latest copy can damage your reputation as a publisher, because we live in an increasingly real-time web where technical difficulties and stale content are rarely tolerated by visitors. I don't want to upset my readers like this, so I set aside a few hours to automate the purge process so it's not a chore to do each time. I write fairly regularly, and stepping into my MaxCDN control panel for each new post that comes out is tiring. What I love about MaxCDN is their Rest Web Service (RWS) API. MaxCDN have a small perl repo on Github which demonstrates how to use the API. I made a tiny perl script to automate the purging process and rebuild assets on their edge servers. This script is for MaxCDN power users and requires some knowledge of REST and perl environments. Do not blindly start using the API like I did. It takes some work to get it all working smoothly, ninja or not.

My blog is a Ghost installation, so I don't have the power of such things as W3 total cache, which is a handy plugin for managing caching if you run Wordpress. I treat my whole blog as a living document and frequently revisit old posts to correct any inaccuracies, so the blog is forever shifting. Frankly I lose face if the latest copy is not being served and I have to resort to busting the cache, loading a page in a private session, or simply brute forcing the blog to serve the latest copy by using the purge all button. You might ask why I use a CDN if I am changing things all the time? Well a CDN is not just for static assets like large downloads and rarely-changed things like Javascript and images. That is one use of a CDN: bulky binary blobs, but it can be used for publishing blog posts too. I wrote about why you would want to use a CDN for blogging here.

When I first started using MaxCDN to serve living documents, I was always scared of the purge all button, because I knew all their edge locations were busy grabbing new copies of all my posts. Ever since they introduced the origin shield feature, I no longer have to worry about this. Origin Shield just uses one PoP (Point of presence), namely the Virginia edge to grab my content. Then it intelligently serves this content on other edge locations. It's a lot more efficient and doesn't hammer my servers as much. It's also more gentle on MaxCDN's servers too, which is always a win. I would be more wary of purging every asset from their servers if you run a massive blog. Thankfully I am a one man show and don't have too many binary blob assets. However, that could change as my blog gathers more steam and I push out more posts.

Also Noteworthy: