PHPackages                             kenshodigital/kirby-cloudflare - 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

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

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

Enables Cloudflare Cache for pages in Kirby projects.

1.0.0(1mo ago)05MITPHPPHP ^8.5

Since Jul 2Pushed 1mo agoCompare

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

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

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

[](#kirby-cloudflare)

Enables [Cloudflare Cache](https://developers.cloudflare.com/cache/) for pages in [Kirby](https://getkirby.com) projects.

General
-------

[](#general)

If you’re proxying a website through Cloudflare, static assets are typically already cached. HTML pages aren’t cached by default, though. While this can be easily enabled with a basic Cache Rule in Cloudflare, the CDN cannot determine which pages are 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 or expires.

The plugin provides a custom cache driver 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 caching pages on the server, the cache driver only sends the appropriate Cloudflare headers, and leaves the actual caching to the CDN.

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

### Further reading

[](#further-reading)

- [Caching guide](https://getkirby.com/docs/guide/cache)

Usage
-----

[](#usage)

### Installation

[](#installation)

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

### Setup

[](#setup)

#### Cloudflare

[](#cloudflare)

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)

Enable the page cache and set the cache type to `cloudflare` in your `config.php`. Make sure to provide your zone ID along with your API token.

```
