PHPackages                             bnomei/kirby-nitro - 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. bnomei/kirby-nitro

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

bnomei/kirby-nitro
==================

Nitro speeds up the loading of content in your Kirby project.

2.1.1(1y ago)925[1 issues](https://github.com/bnomei/kirby-nitro/issues)MITPHPPHP &gt;=8.2.0

Since Jul 19Pushed 11mo ago2 watchersCompare

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

READMEChangelog (9)DependenciesVersions (10)Used By (0)

> ARCHIVED MAY 2025. suggested alternative:

⛽️ Kirby Nitro
==============

[](#️-kirby-nitro)

[![Release](https://camo.githubusercontent.com/5c8378c68b536a802b563cdcb83d0585521727ff9021565edecf8770cf0a43db/68747470733a2f2f666c61742e62616467656e2e6e65742f7061636b61676973742f762f626e6f6d65692f6b697262792d6e6974726f3f636f6c6f723d6165383166662669636f6e3d676974687562266c6162656c)](https://camo.githubusercontent.com/5c8378c68b536a802b563cdcb83d0585521727ff9021565edecf8770cf0a43db/68747470733a2f2f666c61742e62616467656e2e6e65742f7061636b61676973742f762f626e6f6d65692f6b697262792d6e6974726f3f636f6c6f723d6165383166662669636f6e3d676974687562266c6162656c)[![Discord](https://camo.githubusercontent.com/36eaef1b06f4996feb7587aa3281dcbd658e57535bc6b5e10110ed108e7a7a03/68747470733a2f2f666c61742e62616467656e2e6e65742f62616467652f646973636f72642f626e6f6d65693f636f6c6f723d3732383964612669636f6e3d646973636f7264266c6162656c)](https://discordapp.com/users/bnomei)[![Buymecoffee](https://camo.githubusercontent.com/62e55d1129b82bf9c2fd4656451e81ab87a9787e7c9676ca58276532ed9666ee/68747470733a2f2f666c61742e62616467656e2e6e65742f62616467652f69636f6e2f646f6e6174653f69636f6e3d6275796d6561636f6666656526636f6c6f723d464638313346266c6162656c)](https://www.buymeacoffee.com/bnomei)

Nitro speeds up the loading of content in your Kirby project.

Installation
------------

[](#installation)

- unzip [master.zip](https://github.com/bnomei/kirby-nitro/archive/master.zip) as folder `site/plugins/kirby-nitro`or
- `git submodule add https://github.com/bnomei/kirby-nitro.git site/plugins/kirby-nitro` or
- `composer require bnomei/kirby-nitro`

Checklist: When to use this plugin?
-----------------------------------

[](#checklist-when-to-use-this-plugin)

- You load more than 100 but less than 2000 models (pages/files/users) in a **single request**?
- You have less than 4000 models or 2 MB combined TXT files in your project?
- If you load less, you do not need any performance plugins apart from maybe a [key-value caching helper](https://github.com/bnomei/kirby3-lapse).
- If you load more, you should consider [Boost](https://github.com/bnomei/kirby3-boost)or [Khulan](https://github.com/bnomei/kirby-mongodb) instead.
- If you need to process multiple requests fully concurrently you should not use this plugin. But from my experience most Kirby projects do not need that.

Global &amp; Atomic Cache
-------------------------

[](#global--atomic-cache)

The Nitro cache is a global cache. This means that the cache is shared between all HTTP\_HOST environments. This will make it behave like a single database connection.

The Nitro cache is by default an atomic cache. This means that the cache will block the cache file for the full duration of your request to maintain data consistency. This will make it behave like a database with locks.

Warning

No matter how many php-fpm workers you have, only one will be running at a time when Nitro is in atomic mode! You have been warned! But this is the only way to guarantee data consistency, and it will still be wicked fast.

Usecase
-------

[](#usecase)

The plugin will speed up Kirby setups, loading 100-2000 page models in a single request by providing a special cache. It solves the three major performance bottlenecks in Kirby that I know of and links the cache between CLI and HTTP requests.

It does this by:

- Providing a regular file cache you can use yourself. But the cache is always fully loaded in every request and only uses a single file, which makes it wicked fast.
- Optionally you can use that cache for storing the UUID to page ID relations. So instead of loading a single file for every page model UUID resolution, the cache will have them ready instantly.
- It allows you to store the TXT content of selected page/file/user models in the cache to speed up the loading time of content.
- I uses a second cache, which will cache `Dir::index` results. This will skip crawling the file structure step in populating the full index from the cache until you update any page/file.

Setup
-----

[](#setup)

For each template you want to be cached you need to use a model to add the content cache logic using a trait.

**site/models/default.php**

```
class DefaultPage extends \Kirby\Cms\Page
{
    use \Bnomei\ModelWithNitro;
}
```

or

**site/models/article.php**

```
class ArticlePage extends \Kirby\Cms\Page
{
    use \Bnomei\ModelWithNitro;
}
```

Note

You can also use the trait for user models. File models are patched automatically.

Using the Cache
---------------

[](#using-the-cache)

You can use the single-file-based cache of Nitro to store your own key-value pairs, just like with a regular cache in Kirby.

```
nitro()->cache()->set('mykey', 'value');
nitro()->cache()->set('mykey', 'value', 1);

$value = nitro()->cache()->get('mykey');
$value = nitro()->cache()->getOrSet('mykey', fn() => 'value');
```

The Nitro cache is a bit smarter than the default cache in Kirby. It allows you optionally provide keys as arrays, it will serialize values automatically (like Kirby fields to their `->value()`) and storing a value can be canceled.

```
nitro()->cache()->set(['articles', $page->slug()], $page->title());

nitro()->cache()->set('test', function () {
    // ... some logic
    if($cancel) {
        throw new \Bnomei\Nitro\AbortCachingExeption();
    }
});
```

Warning

Since the Nitro cache is fully loaded with every request I would not advise to store too many big chunks of data (like HTML output or when having too many models in total).

Using the Cache Driver in Kirby
-------------------------------

[](#using-the-cache-driver-in-kirby)

You can also use the singe-file-based cache of Nitro as a **cache driver** for Kirby. This will allow you to use it for caching of other extensions in Kirby.

Note

I would highly recommend to use the Nitro cache for Kirby's UUID cache.

**site/config/config.php**

```
return [
    // ... other options

    // use nitro as cache driver for storing uuids
    // instead of the default file-based cache
    'cache' => [
        'uuid' => [
            'type' => 'nitro',
        ],
    ],

    // example: in Lapse plugin
    'bnomei.lapse.cache' => [
        'type' => 'nitro',
    ],
];
```

Settings
--------

[](#settings)

bnomei.nitro.DefaultDescriptionglobal`true`all HTTP\_HOSTs will share the same cacheatomic`true`will lock the cache while a request is processed to achieve data consistencysleep`1000`duration in MICRO seconds before checking the lock againauto-unlock-cache`true`will forcibly unlock the cache if it could not get a lock within set timeauto-clean-cache`true`will clean the cache once before the first get()patch-dir-classalways onmonkey-patch the \\Kirby\\Filesystem\\Dir class to use Nitro for cachingpatch-files-class`true`monkey-patch the \\Kirby\\CMS\\Files class to use Nitro for caching its contentmax-dirty-cache`512`write every N changes or on destructjson-encode-flags`JSON_THROW_ON_ERROR`model.read`true`read from cache for all models that use the ModelWithNitro traitmodel.write`true`write to cache for all models that use the ModelWithNitro traitDisclaimer
----------

[](#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](https://github.com/bnomei/kirby-nitro/issues/new).

License
-------

[](#license)

[MIT](https://opensource.org/licenses/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.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance44

Moderate activity, may be stable

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~22 days

Recently: every ~39 days

Total

9

Last Release

484d ago

Major Versions

1.1.3 → 2.0.02024-08-10

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3265642?v=4)[Bruno Meilick](/maintainers/bnomei)[@bnomei](https://github.com/bnomei)

---

Top Contributors

[![bnomei](https://avatars.githubusercontent.com/u/3265642?v=4)](https://github.com/bnomei "bnomei (33 commits)")

---

Tags

cachecontentdirectoryfilefilesindexkirbykirby-cmskirby-pluginkirby4kirby5modelpageperformanceuserpageperformancemodelusercachefilefilescontentindexdirectorykirbykirby-pluginkirby-cms

### Embed Badge

![Health badge](/badges/bnomei-kirby-nitro/health.svg)

```
[![Health](https://phpackages.com/badges/bnomei-kirby-nitro/health.svg)](https://phpackages.com/packages/bnomei-kirby-nitro)
```

###  Alternatives

[bnomei/kirby3-redis-cachedriver

Advanced Redis cache-driver with in-memory store, transactions and preloading

101.7k](/packages/bnomei-kirby3-redis-cachedriver)[bnomei/kirby-janitor

Kirby Plugin for running commands like cleaning the cache from within the Panel, PHP code or a cronjob

922.8k1](/packages/bnomei-kirby-janitor)[bnomei/kirby3-recently-modified

Kirby Section to display recently modified content pages

309.3k](/packages/bnomei-kirby3-recently-modified)[bnomei/kirby3-janitor

Kirby Plugin for running commands like cleaning the cache from within the Panel, PHP code or a cronjob

9339.9k2](/packages/bnomei-kirby3-janitor)[bnomei/kirby3-redirects

Setup performant HTTP Status Code Redirects from within the Kirby Panel

269.1k](/packages/bnomei-kirby3-redirects)[bnomei/kirby3-pageviewcounter

Track Page view count and last visited timestamp

251.1k](/packages/bnomei-kirby3-pageviewcounter)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
