PHPackages                             acpl/flarum-lscache - 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. acpl/flarum-lscache

ActiveFlarum-extension[Caching](/categories/caching)

acpl/flarum-lscache
===================

LSCache implementation for Flarum.

v3.3.6(1mo ago)74.4k↑50%2GPL-3.0-or-laterPHPPHP &gt;=8.1CI passing

Since Nov 16Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/android-com-pl/flarum-lscache)[ Packagist](https://packagist.org/packages/acpl/flarum-lscache)[ GitHub Sponsors](https://github.com/android-com-pl/flarum-lscache?sponsor=1)[ RSS](/packages/acpl-flarum-lscache/feed)WikiDiscussions 4.x Synced 1mo ago

READMEChangelog (10)Dependencies (20)Versions (45)Used By (0)

LiteSpeed Cache for Flarum
==========================

[](#litespeed-cache-for-flarum)

[![Latest Stable Version](https://camo.githubusercontent.com/03d6d803e463e6754857a07ea9098f5191226007a83e1f0fd2907b9406ee5364/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6163706c2f666c6172756d2d6c736361636865)](https://packagist.org/packages/acpl/flarum-lscache) [![Total Downloads](https://camo.githubusercontent.com/33fea95d610f230590d8a3d175516f5ba36eeeb5095b6c00a8905a625520ebcb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6163706c2f666c6172756d2d6c7363616368652e737667)](https://packagist.org/packages/acpl/flarum-lscache) [![GitHub Sponsors](https://camo.githubusercontent.com/5c68940361d1e0d29b21caab7c8c56a3eacd733d5825f1331e17ea69f5e105ba/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f6e6174652d2545322539442541342d2532336462363161322e7376673f266c6f676f3d676974687562266c6f676f436f6c6f723d7768697465266c6162656c436f6c6f723d313831373137)](https://github.com/android-com-pl/flarum-lscache?sponsor=1)

A [Flarum](http://flarum.org) extension. Integrates [LSCache](https://lscache.io/) with your forum.

Requires a LiteSpeed Web Server or OpenLiteSpeed.

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

[](#installation)

### Install with composer:

[](#install-with-composer)

```
composer require acpl/flarum-lscache
```

Upon initial activation, the extension will add its configurations to the `.htaccess` file. It's recommended to back up your `.htaccess` file before installing the extension.

### Updating

[](#updating)

```
composer update acpl/flarum-lscache
php flarum migrate
php flarum cache:clear
```

### Cache Management

[](#cache-management)

This extension smartly manages the cache by purging it only where needed. For instance, when a new post is added in a discussion, the cache for that specific discussion, its tags, and the homepage are purged.

When you clear the Flarum cache, the LSCache is also cleared automatically unless you disable this feature in the settings.

You can clear the LSCache without clearing the Flarum cache via the admin panel. This option is available under the standard Flarum cache clearing option. There is also the `php flarum lscache:clear` command. The command supports the `--path` argument. For example, `php flarum lscache:clear --path=/tags --path=/d/1-test`. You can use this if you only want to purge specific paths instead of the entire cache.

---

For Developers
--------------

[](#for-developers)

Important

These instructions are for Flarum 2.0. For Flarum 1.x documentation, please refer to: [Flarum 1.x Guide](https://github.com/android-com-pl/flarum-lscache/blob/3.x/README.md#for-developers)

### How the Extension Tags Paths

[](#how-the-extension-tags-paths)

First, it's useful to understand how the extension adds LSCache tags to forum paths. The extension uses route names. For example, if you registered routes for a resource in your extension named `examples`:

```
(new Extend\Routes('api'))
    ->get('/examples', 'examples.index', ExamplesListController::class)
    ->post('/examples', 'examples.create', ExamplesCreateController::class)
    // and so on
```

The extension will automatically add the following tags to the response:

- For paths with the `.index` suffix (e.g., `examples.index`):
    - A tag corresponding to the main resource name is added (e.g., `examples`)
- For other paths:
    - A tag with the full path name is added (e.g., `examples.overview`)
- If the request contains parameters:
    - For the `id` parameter: a tag `{resource}_{id}` is added (e.g., `example_1`)
    - For the `slug` parameter: a tag `{resource}_{slug}` is added (e.g., `example_example-slug`)

Tip

To see the cache tags added for a given request, check the value of the `X-LiteSpeed-Tag` header in the Network tab of DevTools.

### Purging Cache

[](#purging-cache)

By default, the extension purges the cache for a resource with a given ID if it detects successful requests to paths with the suffixes `.create`, `.update`, `.delete`.

To disable this behavior and add your own event handling, add your resource to the `$resourcesSupportedByEvent` array:

```
// 💡 resource name should be in singular form
\Acpl\FlarumLSCache\Utility\LSCachePurger::$resourcesSupportedByEvent[] = 'example'

return [
    // ... your current extenders
];
```

Then you can create an event listener:

```
// extend.php
use Flarum\Extend;

return [
    // ... your current extenders
    (new Extend\Conditional)
        ->whenExtensionEnabled('acpl-lscache', [
            (new Extend\Event)->listen(ExampleUpdated::class, ExampleUpdatedListener::class)
        ]),
];
```

```
// ExampleUpdatedListener.php
use Acpl\FlarumLSCache\Listener\AbstractCachePurgeListener;

/** @extends AbstractCachePurgeListener */
class ExampleUpdatedListener extends AbstractCachePurgeListener
{
    protected function addPurgeData(object $event): void
    {
        $this->purger
          // Purge cache tag
          ->addPurgeTag('examples');
          // or purge multiple cache tags
          ->addPurgeTags([
              'examples',
              "examples_{$event->example->id}"
          ]);
          // Purge a single path
          ->addPurgePath('/examples');
          // or purge multiple paths
          ->addPurgePaths([
              '/examples',
              "/examples_{$event->example->id}",
          ]);
    }
}
```

Tip

It is recommended to purge cache tags instead of paths, as they also apply to different versions of the address, e.g., with query strings.

It's also possible to create an event subscriber if you want to group multiple listeners in one class:

```
// extend.php
use Flarum\Extend;

return [
    // ... your current extenders
    (new Extend\Conditional)
        ->whenExtensionEnabled('acpl-lscache', [
            (new Extend\Event)->subscribe(ExampleEventSubscriber::class),
        ]),
];
```

```
// ExampleEventSubscriber.php
use Acpl\FlarumLSCache\Listener\AbstractCachePurgeSubscriber;
use Illuminate\Contracts\Events\Dispatcher;

class ExampleEventSubscriber extends AbstractCachePurgeSubscriber
{
    public function subscribe(Dispatcher $events): void
    {
        $this->addPurgeListener($events, ExampleUpdated::class, [$this, 'handleExampleUpdated']);
        // ... rest of listeners
    }

    public function handleExampleUpdated(ExampleUpdated $event): void
    {
        $this->purger->addPurgeTags([
            'examples',
            "example_{$event->example->id}",
        ]);
    }
    // ... rest of methods
}
```

Links
-----

[](#links)

- [Packagist](https://packagist.org/packages/acpl/flarum-lscache)
- [GitHub](https://github.com/android-com-pl/flarum-lscache)
- [Discuss](https://discuss.flarum.org/d/29475)

###  Health Score

54

—

FairBetter than 97% of packages

Maintenance88

Actively maintained with recent releases

Popularity29

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 76.6% 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 ~38 days

Recently: every ~6 days

Total

42

Last Release

59d ago

Major Versions

0.4.1 → v1.0.02023-05-01

v1.0.2 → v2.0.02023-05-20

2.x-dev → v3.0.02024-09-15

v3.3.5 → v4.0.0-beta.12026-02-23

v3.3.6 → v4.0.0-beta.22026-03-21

PHP version history (4 changes)0.0.1PHP ^7.4||^8.0

v1.0.0PHP &gt;=8.0

v3.0.0PHP &gt;=8.1

v4.0.0-beta.1PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/eeb64214aa3264c9725d7ed0c0d066d3a3539f10152b390845f17532deffe580?d=identicon)[rafaucau](/maintainers/rafaucau)

---

Top Contributors

[![rafaucau](https://avatars.githubusercontent.com/u/25438601?v=4)](https://github.com/rafaucau "rafaucau (216 commits)")[![flarum-bot](https://avatars.githubusercontent.com/u/39334649?v=4)](https://github.com/flarum-bot "flarum-bot (37 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (14 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (14 commits)")[![datlechin](https://avatars.githubusercontent.com/u/56961917?v=4)](https://github.com/datlechin "datlechin (1 commits)")

---

Tags

cacheflarumflarum-extensionhacktoberfestlscachephpcacheflarumlitespeedLSCache

### Embed Badge

![Health badge](/badges/acpl-flarum-lscache/health.svg)

```
[![Health](https://phpackages.com/badges/acpl-flarum-lscache/health.svg)](https://phpackages.com/packages/acpl-flarum-lscache)
```

###  Alternatives

[psr/simple-cache

Common interfaces for simple caching

8.1k727.3M2.1k](/packages/psr-simple-cache)[psr/cache

Common interface for caching libraries

5.2k686.9M1.3k](/packages/psr-cache)[react/cache

Async, Promise-based cache interface for ReactPHP

444112.4M40](/packages/react-cache)[beste/in-memory-cache

A PSR-6 In-Memory cache that can be used as a fallback implementation and/or in tests.

2512.2M6](/packages/beste-in-memory-cache)[anahkiasen/flatten

A package for the Illuminate framework that flattens pages to plain HTML

33113.0k](/packages/anahkiasen-flatten)[rtcamp/nginx-helper

Cleans nginx's fastcgi/proxy cache or redis-cache whenever a post is edited/published. Also provides cloudflare edge cache purging with Cache-Tags.

23517.0k1](/packages/rtcamp-nginx-helper)

PHPackages © 2026

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