In April 2014, we were preparing to launch our data store. At the time, we had a simple WordPress site, and had chosen Fastly as our content delivery network (CDN). We chose Fastly because itâ€™s one of the few CDNs that is not only superfast, but also supports SSL CDN for Apex Domains (aka 2nd level domains). We require SSL communication for all our web properties because Crate.io is included in the HSTS preload list of Chromium. Combined with Dyn, our DNS provider, weâ€™re able to cache not only cdn.crate.io for static assets, but also (and more importantly) our main property, https://crate.io.
Fastly is built from Varnish, an open source web application accelerator that is also known as a caching HTTP reverse proxy. You install it in front of any server that speaks HTTP and configure it to cache the contents.
Before the April 2014 launch, we had installed the Fastly WordPress plugin. We knew that WordPress wasnâ€™t optimized for speed (most dynamic sites are not, since the php needs to be prepared every time a HTTP request comes along). CDN caching plugins make the site load much faster — caching really quickly and then purging quickly is the secret. Yet, itâ€™s a difficult balance to maintain.
We were preparing to launch Crate on April 24, at the Next Web Conference in Amsterdam. To present on stage at the conference, we had to get as many upvotes as possible, since only 10 companies with the most votes got to present. To help drum up support, we began emailing friends and family on April 18, hoping to collect the votes we needed. Then, like a bolt of lightning from the sky, someone put us on Hacker News and we suddenly shot up to the #1 spot.
Take a look at a few charts from Fastlyâ€™s analytics (demo here). This is what traffic looked like jumping from a sleepy company in half stealth mode to #1 on Hacker News:
(a screen shot taken from Fastly’s analytics)
As our traffic increased, our website performance remained consistently strong, which we attribute to Fastlyâ€™s WordPress Plugin.
The great thing about Fastlyâ€™s WordPress plugin is that it does all the necessary purging immediately and automatically. As soon as you edit a post, add a category, or receive a new comment on your WordPress-based website, the plugin quickly purges all the affected URLs whose content has changed. And, of course, it does so through the Fastly API for PHP. To get it working, you need to enter your API Key and Service ID once, which you can get from your Fastly account settings.
Other than this GitHub page, there isnâ€™t a lot of documentation about the plugin. Iâ€™ve decided to correct that wrong here:
You can either install from source, or from the WordPress plugin directory.
Once your plugin is installed and activated, you should be able to set up the Fastly plugin inside your WordPress config panel. Simply navigate to Settings â†’ Fastly and fill in the required fields with your API key and Service id.
Where and how do I get these?
If you haven’t already sent Fastly a support request asking to have the WordPress feature turned on for your account, you should do so now. Then add a new WordPress config to a Service and set up the path to the WordPress install.
http://blog.example.com/, your path is
http://example.com/blog/, your path is
Finally deploy the new version of the Service and you should be given your API credentials.
You may have to disable other caching plugins like W3TotalCache or WP-Cache to avoid getting odd cache behaviour.
You can learn more about Fastly here: http://www.fastly.com/