We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 44833
    • 13 Posts
    We looked everywhere for this functionality and couldn't find anything so we've taken a crack at creating our own.

    Small plugin that uses 3 system settings to connect to the CloudFlare API and purge your sites CloudFlare cache when clicking the "Clear Cache" button in the MODX manager (the OnBeforeCacheUpdate system event).

    The project's on GitHub at https://github.com/DashMedia/PurgeCloudFlare/ and we'd love any feedback or suggestions for improvements.

    Hope this helps someone else out there.

    Updateed with details about version 2.0:

    The new version uses the CloudFlare API to purge the CloudFlare cache for your website, PurgeCloudFlare will purge single pages from CloudFlare when they are save within the MODX Manager, and purge the entire cache when the "Clear Cache" button is pressed.

    We also now have support for multiple contexts with different domains. You can also use a context setting to skip over a specific context.

    Another great new feature is that saving a resource will individually clear that page from CloudFlare along with the ancestors in the resource tree. For example: when I update a news item, the news item listing page also gets cleared.

    Read the docs, take, browse the source, announce bugs, or submit pull requests at https://github.com/DashMedia/PurgeCloudFlare/

    We recommend installing via the MODX Extras directory at http://modx.com/extras/package/purgecloudflare2 for easy upgrades. [ed. note: dashmedia last edited this post 9 years, 1 month ago.]
      • 40092
      • 265 Posts
      This could be quite usefull in the project i am currently working on.
      Thank you for sharing! smiley
        • 44833
        • 13 Posts
        Thanks, we've submitted to the extras directory. Hopefully it will be approved and you'll be able to easily install and potentially update from there.
          • 44833
          • 13 Posts
          Now available in the extras directory at http://modx.com/extras/package/purgecloudflare2

          It's labeled as RC1 but it appears to be totally stable. Thankfully the CloudFlare APIs are very straight forward.
            • 44833
            • 13 Posts
            We've update PurgeCloudFlare to 1.1.1-pl with some awesome new features:


            • There are now only 2x system settings to configure. cf_api_key and cf_email. The site now discovers the domain from the http_host
            • We've added support for multiple contexts assuming each context is a separate website setup on the same CloudFlare account. The clear cache button will now purge CloudFlare for each context (apart from mgr). There's an optional cf_skip=1 context setting if you'd like PurgeCloudFlare to skip a particular context.
            • Big news: We've added a second plugin so that each time you save a resource, MODX will clear the single resource URL from CloudFlare's cache.

            The main benefit of these changes is that you can now use CloudFlares page rules to force caching for more of the MODX resource requests that would otherwise have been sent through to your server. Each time you update a resource in MODX your cache for that specific URL will be cleared in CloudFlare.

            Check it out at http://modx.com/extras/package/purgecloudflare2
              • 18367
              • 834 Posts
              Do you put the account details in the Name field or the Value fields when updating in System settings?
                Content Creator and Copywriter
                • 14646
                • 8 Posts
                @MarkG - Update the value fields with your API Key and Email Address.

                I've just updated the OP to reflect the newest version of the extra. We were slowly adding featured and decided to do a refactor and move the transport package building over to Repoman https://github.com/craftsmancoding/repoman.

                For the most basic setup setup you just need to update two system settings:

                • cloudflare.api_key - Your CloudFlare API Key
                • cloudflare.email_address - Your CloudFlare Email Address

                Both of these can be found from inside your CF account by going to the "Account" page.

                If you're working with multiple contexts or would like to enable CF Development mode when clearing the cache check out the optional extra settings at GitHubhttps://github.com/DashMedia/PurgeCloudFlare.
                  Jonathan Haslett
                  Director at https://dash.marketing/
                  MODX Slack @jonathanhaslett
                  • 18367
                  • 834 Posts
                  Quote from: jonhas at Apr 07, 2015, 11:57 PM
                  @MarkG - Update the value fields with your API Key and Email Address.


                  Jonathan,

                  so glad I asked the question. When I first tried to update the fields it put the info in the Name form field. And I was like: "No that doesn't seem right. Maybe I'll leave it alone until I get an answer"

                  As I said, so glad I did, who knows what would have happened if I had saved it. Not pretty I'll bet.

                  Thanks again.
                    Content Creator and Copywriter