Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

 

No more waiting: introducing SilverStripe-CloudFlare

Developed by SilverStripe Professional Partner, Stead Lane, this innovative module helps you see content changes instantly. 

Read post

Developer Reece Alexander of Stead Lane (SilverStripe Professional Partner) has created an innovative module that is proving to have great success: SilverStripe-CloudFlare. The module will make life much easier for content managers.

What is CloudFlare?

CloudFlare is a content delivery network (CDN)—a distributed network of servers that helps improve page load speeds, reduce bandwidth and CPU (central processing unit) usage on the server by caching website content.

What does SilverStripe-CloudFlare do?

SilverStripe-CloudFlare clears the cache and allows you to see changes instantly as you make them. In a typical CDN provided website setup, you can expect a website change to take hours, or even days, to show for your end users. These days are gone: SilverStripe-CloudFlare uses the CloudFlare API to purge pages that have been changed as soon as you publish them; you don’t have to log into the CloudFlare dashboard and purge the cache yourself.

The team at Stead Lane have shared this module within the wider SilverStripe open source community for anyone to access. The intention of this module was to eliminate a waiting process and improve efficiency while using SilverStripe CMS. Immediate positive feedback from the community has proved its intent.

Purge

Features

  • Dynamic zone ID detection: You can have multiple domains under your CloudFlare account. This module dynamically retrieves the CloudFlare Zone ID for the domain you have accessed the CMS administration with. You need to make sure this domain is correctly registered under your CloudFlare account.

  • Intelligent purging:

    • If you modify the title or URL of any page, all cache for the Zone will be purged
    • If you modify the contents of any page, only the cache for that page will be purged
    • If you modify any page that has a parent, the page you modified and all of its parents will be purged too
  • Manual purging: The administration area for this module allows you to either purge all CSS files, all javascript files, or all image files.

Installation

This module only supports installation via composer:

composer require steadlane/silverstripe-cloudflare

Run /dev/build afterwards and ?flush=1 for good measure for SilverStripe to become aware of this module.

Configuration

Configuration for this module is minimal, you need only define two constants in mysite/_config.php:

define('CLOUDFLARE_AUTH_EMAIL', 'mycloudflare@example.com.au'); 
define('CLOUDFLARE_AUTH_KEY', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ');

If you have multiple domains registered under a single account in CloudFlare, the module is versatile in automatically recognising the Zone ID that is to be used alongside the domain the module is installed on. Other than the two initial configuration settings to set up the module, there is no further setup required, making it practical and easily accessible.

It is recommended that the user adds these cache rules to CloudFlare cache rules:

Rule

Comments

example.com.au/*stage=Stage*
It is outside the scope of this module to handle cache purging for drafts. Drafts should never need to be cached as they're not usable on the front end
example.com.au/Security/*
Prevents caching of the login page etc 
example.com.au/admin/*
Prevents caching of the Administrator Pane
example.com.au/dev/*
Prevents caching of the development tools

The development of this module and its accessibility to the wider SilverStripe open source community will improve the efficiency of content creators and content managers globally.

About the author
Adam Stead

Adam Stead is the co-founder and director of Gold Coast digital agency, Stead Lane. As previous vice president of the Web Industry Professionals Association (WIPA) and with over 17 years in the web industry, Adam’s knowledge and experience is a core asset to Stead Lane. In 2008, Adam made the key decision to partner with SilverStripe and has since deployed over 250 SilverStripe CMS websites.

Post your comment

Comments

No one has commented on this page yet.

RSS feed for comments on this page | RSS feed for all comments