PHPackages                             kenshodigital/kirby-cloudflare-cache - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. kenshodigital/kirby-cloudflare-cache

ActiveKirby-plugin[Caching](/categories/caching)

kenshodigital/kirby-cloudflare-cache
====================================

Provides Cloudflare Cache integration for Kirby projects.

1.0.0(today)00MITPHPPHP ^8.5

Since Jul 1Pushed todayCompare

[ Source](https://github.com/kenshodigital/kirby-cloudflare-cache)[ Packagist](https://packagist.org/packages/kenshodigital/kirby-cloudflare-cache)[ RSS](/packages/kenshodigital-kirby-cloudflare-cache/feed)WikiDiscussions main Synced today

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

Kirby Cloudflare
================

[](#kirby-cloudflare)

Provides [Cloudflare](https://www.cloudflare.com) integration for [Kirby](https://getkirby.com) projects.

General
-------

[](#general)

### Caching

[](#caching)

If you’re proxying a website through Cloudflare, static assets are already cached in most cases. HTML pages aren’t cached by default, though. While this can be easily enabled with a basic Cache Rule in Cloudflare, the CDN has no way to tell what pages are actually considered cacheable by Kirby’s standards, or when content has been updated in the CMS. It simply caches every page until the cache gets manually purged again or expires.

The plugin provides a custom cache driver intended to be used for Kirby’s page cache. This leverages Kirby’s core logic for determining what pages are cacheable and when to flush the cache. Instead of actually caching a page on the file system or in some key-value store, the cache driver only sends the appropriate Cloudflare headers, and leaves the caching itself to the CDN.

It also takes care of purging the cache via API when appropriate, making the overall caching behavior consistent with Kirby’s built-in page cache.

#### Further reading

[](#further-reading)

- [Cloudflare Cache](https://developers.cloudflare.com/cache/)
- [Kirby caching guide](https://getkirby.com/docs/guide/cache)

Usage
-----

[](#usage)

### Installation

[](#installation)

```
composer require kenshodigital/kirby-cloudflare ^1.0
```

### Setup

[](#setup)

#### Caching

[](#caching-1)

##### Cloudflare

[](#cloudflare)

As mentioned, the domain has to be proxied through Cloudflare and a **cache rule** needs to be set up to actually cache all eligible responses, including HTML pages.

An **API token** with *Cache Purge* permission for the domain is also required.

###### Further reading

[](#further-reading-1)

- [Cache rules](https://developers.cloudflare.com/cache/how-to/cache-rules/)
- [API token](https://developers.cloudflare.com/fundamentals/api/get-started/create-token/)

##### Kirby

[](#kirby)

In your `config.php`, make sure to enable the page cache, set the cache type to `cloudflare`, and provide your zone ID along with your API token.

```
