PHPackages                             label-li/laravel-page-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. label-li/laravel-page-cache

ActiveLibrary[Caching](/categories/caching)

label-li/laravel-page-cache
===========================

Page Cache for Laravel PHP Static Page

1.1.7(4y ago)087MITPHPPHP ^7.3|^8.0

Since Aug 15Pushed 4y ago1 watchersCompare

[ Source](https://github.com/LabelLi/laravel-page-cache)[ Packagist](https://packagist.org/packages/label-li/laravel-page-cache)[ RSS](/packages/label-li-laravel-page-cache/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (1)Versions (4)Used By (0)

Laravel Page Cache
==================

[](#laravel-page-cache)

[![Latest Stable Version](https://camo.githubusercontent.com/fff1a1889cb0e5b2aef93a6eb91dec5e950f8ed317b8ef1c934df31e48ed6625/687474703a2f2f706f7365722e707567782e6f72672f6c6162656c2d6c692f6c61726176656c2d706167652d63616368652f76)](https://packagist.org/packages/label-li/laravel-page-cache)[![License](https://camo.githubusercontent.com/c3982a5d88463a14bcb69cd284ba78d06b8d27d1040800ffa665b272231fe651/687474703a2f2f706f7365722e707567782e6f72672f6c6162656c2d6c692f6c61726176656c2d706167652d63616368652f6c6963656e7365)](https://packagist.org/packages/label-li/laravel-page-cache)

This package allows you to easily cache responses as static files on disk for lightning fast page loads.

- [Introduction](#introduction)
- [Installation](#installation)
    - [Middleware](#middleware)
- [Config](#config)
- [Usage](#usage)
- [Credit](#credit)

This package can cache static PHP page on local disk to provide a fast loading of pages

Introduction
------------

[](#introduction)

It would be a heavy loading if lots of visitors plus the page loading lots of content from database with lots of logic Page cache can reduce the loading.

installation
------------

[](#installation)

1. Install package with composer:

```
composer require label-li/laravel-page-cache

```

2. Publish the config to `config/pagecache.config`

```
php artisan vendor:publish --provider="LabelLi\LaravelPageCache\PageCacheServiceProvider"
```

### Middleware

[](#middleware)

> If you want to cache all route in middleware `web`, i.e., all http traffics:

1. Open `app/Http/Kernel.php`
2. Copy `\LabelLi\LaravelPageCache\Middleware\CacheResponse::class,` as a new line to the `web` middleware group:

```
protected $middlewareGroups = [
    'web' => [
        \LabelLi\LaravelPageCache\Middleware\CacheResponse::class,
        ...
    ],
];
```

> If you want to cache specific route `page-cache`:

1. Open `app/Http/Kernel.php`
2. Copy `'page-cache' => \LabelLi\LaravelPageCache\Middleware\CacheResponse::class,` as a new line to the `$routeMiddleware`:

```
protected $routeMiddleware = [
    'page-cache' => \LabelLi\LaravelPageCache\Middleware\CacheResponse::class,
    ...
];
```

Config
------

[](#config)

Change the value in `config/pagecache.php` to what you want:

```
'CacheTime' => 3600, // In seconds
'CachePath' => 'pagecache', // In storage
```

Usage
-----

[](#usage)

### Using the middleware

[](#using-the-middleware)

> If you choose to cache specific route, e.g. `page-cache`, use the `page-cache` middleware as follow:

```
Route::middleware('page-cache')->get('/page', 'PageController@show');
```

`/page` will be cached to a file under the `storage/**$CachePath**` directory.

### Clearing the cache

[](#clearing-the-cache)

The cache will be cleared with the `CacheTime` set in `config/pagecache.php`. It is default 3600s.

If you want to clear it manually, please run the following command

```
php artisan PageCache:clear

```

You may optionally pass a URL slug to the command, to only delete the cache for a specific page:

```
php artisan PageCache:clear {slug}

```

To clear everything under a given path, use the `--recursive` flag:

```
php artisan PageCache:clear {slug} --recursive

```

### Remark

[](#remark)

If the Console function is not working, most likely to be the problem of permission for the cache folder. Please check with `ls -la` to check for the permission.

Credit
------

[](#credit)

Thanks to [Joseph Silber](https://github.com/JosephSilber). The idea to run cache function directly at middleware is from his [package](https://github.com/JosephSilber/page-cache). His package is very great but I have different usage. So I write another page cache package to archive my usage.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

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 ~0 days

Total

2

Last Release

1738d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/48414171404bef45e4cf704293728e2d0a1e8e7e67af4d682d39d4cf194eea73?d=identicon)[labelwa](/maintainers/labelwa)

---

Top Contributors

[![LabelLi](https://avatars.githubusercontent.com/u/50449866?v=4)](https://github.com/LabelLi "LabelLi (16 commits)")

---

Tags

cachelaravelphp

### Embed Badge

![Health badge](/badges/label-li-laravel-page-cache/health.svg)

```
[![Health](https://phpackages.com/badges/label-li-laravel-page-cache/health.svg)](https://phpackages.com/packages/label-li-laravel-page-cache)
```

###  Alternatives

[imanghafoori/laravel-widgetize

A minimal yet powerful package to give a better structure and caching opportunity for your Laravel apps.

909137.9k12](/packages/imanghafoori-laravel-widgetize)[swayok/alternative-laravel-cache

Replacements for Laravel's redis and file cache stores that properly implement tagging idea. Powered by cache pool implementations provided by http://www.php-cache.com/

202541.1k6](/packages/swayok-alternative-laravel-cache)[alexmg86/laravel-sub-query

Laravel subquery

7538.4k](/packages/alexmg86-laravel-sub-query)[laravel-enso/rememberable

Model caching dependency for Laravel Enso

2863.2k25](/packages/laravel-enso-rememberable)[byerikas/cache-tags

Allows for Redis/Valkey cache flushing multiple tagged items by a single tag.

1413.9k](/packages/byerikas-cache-tags)

PHPackages © 2026

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