/kirby-cache-rest

Cache operations made developer friendly, in Kirby CMS.

Primary LanguagePHP

Kirby Cache REST

Version License Donate

Cache operations made developer friendly, in Kirby CMS.

Just visit an url to make a cache operation, for example /flush. You will get a JSON response back. It's simple for both users and computers to read the results.

Table of contents

Operations

Flush

Url: /flush

With this operation you will flush the cache, thumbs or any data of your choice.

Path

To flush the cache you need to visit /flush. It can be changed to a path that you prefer.

c::set('cache.rest.flush.path', 'flush');

Roots

This operation flushes both cache and thumbs by default. You can change it to flush any folder.

global $kirby;
c::set('cache.rest.flush.roots', [
    $kirby->roots()->cache(),
    $kirby->roots()->thumbs()
]);

Results

The results will be presented in JSON like this:

{
    "roots": [
        {
            "count": 23,
            "root": "path/to/cache",
            "success": true
        },
        {
            "count": 12,
            "root": "path/to/thumbs",
            "success": false
        }
    ],
    "success": false,
    "flushed_files": 21
}

Additional options

lock

When lock is enabled, the operations will only be accessible by users logged in to the panel.

c::set('cache.rest.flush.lock', false);

Requirements

Disclaimer

This plugin is provided "as is" with no guarantee. Use it at your own risk and always test it yourself before using it in a production environment. If you find any issues, please create a new issue.

License

MIT

It is discouraged to use this plugin in any project that promotes racism, sexism, homophobia, animal abuse, violence or any other form of hate speech.

Credits