Giter Site home page Giter Site logo

arkhi-digital / silverstripe-cloudflare Goto Github PK

View Code? Open in Web Editor NEW
24.0 3.0 9.0 150 KB

This module aims to relieve the stress of using CloudFlare caching with any SilverStripe project. Adds extension hooks that clears CloudFlares cache for a specific page when that page is published or unpublished

License: BSD 3-Clause "New" or "Revised" License

PHP 88.00% CSS 1.55% Scheme 10.46%
cloudflare cloudflare-cache silverstripe

silverstripe-cloudflare's People

Contributors

adam-stead avatar andrewpike avatar robbieaverill avatar zanderwar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

silverstripe-cloudflare's Issues

DataObject Support?

Does the module support triggering a purge on the saving on DataObjects? Or just Pages?

e.g. When a new Testimonial DO is added, the related Testimonials Page should be purged.
Would also be good to be able to define which other pages/URLs need purging when a Page is edited. e.g. Also purge the Home page when a new News Article page is added (as the Home page lists latest news).

ZoneID error

The request to find the zone ID is returning no results.

However, I'm sure I have the correct credentials. Is there any way to debug this problem?

DRY a bit more in the purging methods

It'd be nice to see the purging methods be centralised a little bit more. In my opinion, you have two types of purge request:

  • Everything
  • Specific file(s)

In the case of purgeSingle and purgeMany, purgeSingle could be simply return $this->purgeMany(array($url)).

In the case of the JS, CSS, image purge methods - they should use some centralised logic to find the relevant files and normalise their paths, then use the same purgeMany(array $urls) method to control the actual purging.

Recursive glob is slow and can be improved greatly

If we implode the array we should be able to search for all extensions at once like below

Instead of this:

foreach ($extensions as $ext) {
    $files = array_merge($this->rglob(rtrim($rootDir, "/") . "/*.{$ext}"), $files);
}

It should be

// remove the extension separator as it could be added by extension method by accident
foreach ($extensions as &$ext) {
    $ext = ltrim($ext, '.');
}
$extensions = implode(',', $extensions);
$files = array_merge($this->rglob(rtrim($rootDir, "/") . '/*.{'.$extensions.'}'), $files);

And update rglob() to use GLOB_BRACE

http://stackoverflow.com/a/23969253/2266583 with GLOB_BRACE

For large file systems this would speed up the process exponentially, as currently it iterates the entire file system for each extension so I'm going to put this down as a bug

This needs to be resolved in 3.x compatibility and 4.x compatibility

Implement configurable cURL timeout, and handle errors

If for example I'm using a hostname that CloudFlare doesn't like, the curlRequest method will time out at the PHP defined time limit, and give me nothing useful to look at.

A user configurable timeout limit would be nice.

Also - handling/displaying error messages that indicate a cURL problem.

Add configuration setting for whether to purge parents and siblings or not

The functionality to purge content in parents and siblings recursively is a little heavy handed, but in some applications it may not be necessary.

A configuration setting would be nice, e.g. purge_parents_and_siblings: true (default). This way I could disable that functionality, even in some cases programmatically.

VOTE: Multi Domain Support

In some situations (where the "why" is definitely opinionated) people have multiple domains that access the same content e.g

  • mycooldomain.com - MAIN SITE
  • mycooldomain.net - MASK FOR MAIN SITE
  • mycooldomain.org - MASK FOR MAIN SITE

This module currently only supports the domain name it has been accessed from, that means if you access the administration panel via mycooldomain.com then only cache for the .com variant will be dynamically purged by this module.

Whilst you would think that in this situation, if you were to only purge the .com then the .net and .org will also reflect the purge as these domains only mask the original. Sadly that's not how CloudFlare works as it strictly caches the URL as a whole.

This issue is a poll to see if it would even be worth adding support for the above scenario where this module would also purge cache for all of your URL variants.

Please up vote one of the below comments

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.