CloudFlare CMS Setup

Please Visit the Setup CloudFlare tutorial to get started if you do not have your site setup with cloudflare yet

After installing cloudflare, make sure to examine headers to make sure caching is actually working: https://dri.es/headers

Once you have the CMS setup, head over to Page Rules and set that up.

Drupal 8 Setup

Remember to follow the proper Configuration Management Workflow.  Enable all modules and composer libraries on local then push to live and import the config. If you don't have Business account and not going to cache HTML though CloudFlare then you don't need to setup purge modules and cloud flare connectors.

  1. This module has a few dependencies: CTools, Purge,  URLs queuer (For Free Accounts)
  2. Run this in your root of your site

    composer require d8-contrib-modules/cloudflarephpsdk "1.0.0-alpha5"
    1. Make sure you have the php-mbstring extension installed on your system.

  3. Run

    drush en cloudflare cloudflarepurger purge purge_ui purge_drush purge_queuer_coretags purge_processor_cron --yes
    drush cr
    
    
  4. Go to admin/config/services/cloudflare and enter your CloudFlare creds found here
  5. Go to admin/config/development/performance/purge and add the CloudFlare purger
  6. Run 

    drush cset system.performance cache.page.max_age 31536000
  7. Clear your Varnish & CloudFlare caches.
  8. Once on live site run:

    wget -r -nd --delete-after -l100 --spider http://mydrupalsite/
  9. If your site uses configuration management - set everything on your local and export config via drush. Make sure your performance settings are either in config split or config ignore.

Drupal 7 Setup

1 . Depending on the setup of your Drupal 7 website (with or without composer management) install the following module:

CloudFlare Purge

If your site is on Pantheon install Pantheon Advanced Page Cache

2 . Navigate to Administration » Configuration » Development » Performance » CloudFlare Purge Settings (admin/config/development/performance/cfpurge) and enter your CloudFlare info.

3. Navigating to Administration » Configuration » Development » Performance (admin/config/development/performance) and set the Expiration of Cached Pages to 3 hours or more. This means that CloudFlare will store your page for 3 hours or more if you don't edit or delete it beforehand. You can ignore the other settings on this page. If you enable local caching--which wont be necessary--your local cache will be purged as well.

4. Fix IP settings for your site: add this line to the bottom of your settings.php file:

$_SERVER['REMOTE_ADDR'] = !empty($_SERVER["HTTP_CF_CONNECTING_IP"]) ? $_SERVER["HTTP_CF_CONNECTING_IP"] : $_SERVER["REMOTE_ADDR"];



Wordpress Setup