Getting the Most out of a Free Cloudflare Account

By default, Cloudflare does not cache HTML files. If like me, your traffic is > 50% HTML, that is not making the most of your account. Also, if like me you use WordPress, the HTML pages are slow to create and place a heavier load on your hosting server than a few static images, and css and javascript files. This can result in an analytics graph like the following, with most traffic uncached.

Screenshot from 2015-11-09 15:06:16

So to get around this you need to set two custom page rules in Cloudflare. Go here to do that:

https://www.cloudflare.com/a/page-rules/yourdomain.com

Rule 1: Pass-through for Admin

First set up a rule allowing access to your WordPress admin interface (adjust for your own CMS if different):

Use this as the URL pattern (the first field of the form):

http://yourdomain.com/your_path_to_wordpress_wp-admin_dashboard/*

Adjust the URL to match your own site. Then go through the other fields and turn off all caching. This rule will override the settings for the rest of your site and let you through to change it without caching getting in your way.

Rule 2: Cache Everything Else

Now make a second rule to be an aggressive default. Use this as the url pattern, to match every page on your site:

*yourdomain.com/*

Then set the custom caching drop-down to `Cache everything`. That will let all the static and dynamic HTML pages also be cached in Cloudflare servers all around the world. Now your visitors will be pulling compressed versions of your pages with all the optimisations that Cloudflare apply from the servers closest to them. The result should be a graph more like the one below with lots of cached traffic shown as the orange trace here.

Screenshot from 2015-11-09 15:07:55

This strategy can let you run a high-traffic site off a cheap shared hosting provider like Bluehost or 1and1, which is nice.

TAGS > , ,

Post a comment