The CloudFlare module provides integration with the CloudFlare CDN using the CloudFlare API see: https://api.cloudflare.com/
Special thanks to Wim Leers and Niels Van Mourik for their collaboration and support on all things cache and purge!
You will need to update your composer dependencies:
composer require d8-contrib-modules/cloudflarephpsdk "1.0.0-alpha3"
- You will also need to update to the most recent version of the Purge module.
CloudFlare has limited support for tag clearing to their enterprise tier. To switch to path based purging you will need to:
- uninstall purge_queuer_coretags:
drush dis purge_queuer_coretags
- install purge_queuer_url
drush en purge_queuer_url
- clear stale tag clear requests:
drush ev "delete from queue where name = 'purge'"
drush cset system.performance cache.page.max_age 31536000
(year)- Empty Drupal's page cache:
drush cache-rebuild
- Empty Varnish page cache if you have it.
- Empty CloudFlare's cache.
- Cache clearing by Path (Recommended For Free and Professional) and Tag (Enterprise).
- Restore client's original IP address.
- Report bugs and request features in the GitHub CloudFlare Issue Queue.
- Use pull requests (PRs) to contribute to CloudFlare.
- CTools D8 Module
- Purge D8 Module
- URLs Queuer Module
- CloudFlarePhpSdk - The module relies on the CloudFlarePhpSdk for all interactions with the CloudFlare API. You can check it out here.
- Free Tier does not support cache tags.
- If you attempt to configure tag based purging on Free Tier you will get HTTP 400 error codes in the error log.
- Free Tier don't have a vary by cookie. In English? That means if you login to
your site then authenticated pages can get cached by the CDN. So anonymous users
users see what appear to be authenticated pages (they are not really authenticated).
To work around we recommend that you setup a separate domain for authenticated
users. e.g if your domain is yourdomain.com then setup a second domain for
authenticated users that bypasses cloudflare e.g
edit.yourdomain.com
. In this setup block access to /user on your public domain via .htaccess rules. - By default CloudFlare will cache static resources but not HTML. You need to add a page rule to cache all the things.
drush dl cloudflare purge ctools purge_queuer_url --yes
- From the root of your site run install composer dependencies:
composer require d8-contrib-modules/cloudflarephpsdk "1.0.0-alpha3"
- To install:
drush en cloudflare cloudflarepurger purge purge_ui purge_drush purge_queuer_coretags purge_processor_cron --yes
- Note: If you try to install purge, cloudflare and cloudflare_purger all at once via the UI you will get a one time error on install. This is known issue that is impacting other D8 modules. See here here and here. If you are installing via the UI, recommend the following discrete steps:
- install ctools
- install purge
- install purge_queuer_url
- install cloudflare
- install cloudflarepurger
- install purge_ui purge_drush purge_processor_cron
drush cr
- Go to
admin/config/services/cloudflare
and enter your cloudflare API credentials. - In most environments you will get the CloudFlare edge server ip returned by default. By checking
Restore Client Ip Address
the module can restore the original client IP address on each request. - Under
Host to Bypass CloudFlare
you can specify a host used for authenticated users to edit the site that bypasses CloudFlare. This can help suppress watchdog warnings regarding requests bypassing CloudFlare. - Head over to
/admin/config/development/performance/purge
- Click "Add purger" and select "CloudFlare".
- Click "Add".
drush cset system.performance cache.page.max_age 31536000
(year)- Empty Varnish page cache if you have it.
- Empty CloudFlare's cache.
- Now you are ready to go!
drush dl cloudflare purge ctools --yes
- From the root of your site run install composer dependencies:
composer require d8-contrib-modules/cloudflarephpsdk "1.0.0-alpha3"
- To install:
drush en cloudflare cloudflarepurger purge purge_ui purge_drush purge_queuer_coretags purge_processor_cron --yes
- Note: If you try to install purge, cloudflare and cloudflare_purger all at once via the UI you will get a one time error on install. This is known issue that is impacting other D8 modules. See here here and here. If you are installing via the UI, recommend the following discrete steps:
- install ctools
- install purge
- install cloudflare
- install cloudflarepurger
- install purge_ui purge_drush purge_queuer_coretags purge_processor_cron
drush cr
- Go to
admin/config/services/cloudflare
and enter your cloudflare API credentials. - In most environments you will get the CloudFlare edge server ip returned by default. By checking
Restore Client Ip Address
the module can restore the original client IP address on each request. - Under
Host to Bypass CloudFlare
you can specify a host used for authenticated users to edit the site that bypasses CloudFlare. This can help suppress watchdog warnings regarding requests bypassing CloudFlare. - Head over to
/admin/config/development/performance/purge
- Click "Add purger" and select "CloudFlare".
- Click "Add".
- Now you are ready to go!
In D8 cache clearing is a whole new world. D8 introduces the concept of cache tags. Cache tags represent groupings of content that should be purged when content is created, updated or deleted. Most of this already happens behind the scenes so you don't need to rely on extensive rules like in D6/D7. See here and here for more info on tags. This module has experimental support for Tags (it will still work with path based purging).
The current CloudFlare API only supports 2000 tag purge requests/day. This number is suitable for some but not ALL sites. It's our hope that the limit will be raised in the near future.
Currently CloudFlare does not support 16k cache tag headers which are necessary for taking full advantage of D8's cache tag system.
The current module uses a bloom-filter based approach to work around this limitation. They limit the number of possible cache tags to 4096. However, that means that purging one tag can result in other tags and therefore pages being inadvertently purged. This makes the module unsuitable for high-traffic events.
The CloudFlare purger has been built as a plugin to the Purge module.
At this time no Varnish purger plugins have been written for the Purge module. They are coming soon! We expect Varnish and Acquia Purge D8 purge plugins to appear sometime in the first half of 2016.
This project is built using TravisCI because:
- D.O's testbot does not support composer-based contrib projects.
- D.O's testbot does not support Drupal Code Sniffer.
This project's active development occurs on GitHub:
- Developers are more comfortable with pull-request based contribution that D.O's patch based workflow.
CloudFlare is a trademark of CloudFlare Inc. This module has not been built, maintained or supported by CloudFlare Inc. This is an open source project with no association with CloudFlare Inc. The module uses their API, that's all.