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

ActiveLibrary[Caching](/categories/caching)

siteorigin/laravel-page-cache
=============================

Caches responses as static files on disk for lightning fast page loads.

0.1.3(5y ago)41411[4 issues](https://github.com/siteorigin/laravel-page-cache/issues)MITHTMLPHP &gt;=7.4

Since Mar 5Pushed 5y ago2 watchersCompare

[ Source](https://github.com/siteorigin/laravel-page-cache)[ Packagist](https://packagist.org/packages/siteorigin/laravel-page-cache)[ RSS](/packages/siteorigin-laravel-page-cache/feed)WikiDiscussions develop Synced 1w ago

READMEChangelogDependencies (6)Versions (10)Used By (0)

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

[](#laravel-page-cache)

Laravel Page Cache is a static page caching package. It's heavily inspired by, and forked from [Joseph Silber](https://github.com/JosephSilber)'s [Page Cache](https://github.com/JosephSilber/page-cache) package. This package goes in a slightly different direction, so you should check both to decide which is best for you.

If you combine this package, with [our prefetching Turbolinks package](https://github.com/siteorigin/laravel-turbo), a fast CDN and [Livewire](https://github.com/livewire/livewire) for any dynamic components of your site - you can get a dynamic site, with static site speeds, all without leaving the comfort of Laravel.

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

[](#installation)

*Installation instructions will follow once this is published on Packagist.*

You can publish the configuration file using.

`php artisan vendor:publish --provider="SiteOrigin\PageCache\PageCacheServiceProvider" --tag="config"`

By default, cached files are stored in your app storage public path. So you need to make sure this is linked to your actual public path. To do this, just run `php artisan storage:link`. You can read more [here](https://laravel.com/docs/8.x/filesystem#the-public-disk).

Web Server Configuration
------------------------

[](#web-server-configuration)

You need to tell your web server to look for

Middleware
----------

[](#middleware)

You can add page caching to all your web routes by adding `\SiteOrigin\PageCache\Middleware\CacheResponse::class` to the [web middleware group](https://laravel.com/docs/8.x/middleware#middleware-groups).

You can also use the `page-cache` alias to add caching to individual routes. Something like the following:

```
Route::get('/', function () {
    return view('welcome');
})->name('home')->middleware('cache.headers:public;max_age=2628000;etag', 'page-cache');
```

The `page-cache` alias is registered for you, so you don't need to add this again.

Caching Query Strings
---------------------

[](#caching-query-strings)

This package has support for caching query strings too. This is especially useful for caching paginated URLs. By default, it supports pagination query strings, but if you have other that you'd like to cache, then you can add custom configurations.

### Validating Query Strings

[](#validating-query-strings)

It's important that you validate each request, and return something besides a `200` response if the request isn't formed properly. This prevents an attack where someone makes a lot of requests to random query string URLs, thus filling up your server's disk.

For example, for paginated URLs, you should return a 404 if the page number is out of range.

```
public function index(Request $request)
{
    $articles = Article::simplePaginate(5);

    return view('articles.index', [
        'articles' => $articles->count() ? $articles : abort(404)
    ]);
}
```

The default page caching already makes sure the `page` query string argument is an integer.

### Disabling Pagination Caching

[](#disabling-pagination-caching)

If you don't want to cache paginated URLs, you can disable this in the `page-cache.php` config file.

Change the following line to false `'cache_pagination' => true,`.

### Caching Custom Query String URLs

[](#caching-custom-query-string-urls)

If you want to cache a custom query string URL, you can do this by adding a custom regular expression to `'query_patterns' => [ ... ]` in the `page-cache.php` config file.

Any query string that matches one of the expressions in this list, will be cached. You should do as much validation as possible in the query string as possible, and any additional validation in the controller. Return a `404` if the request seems invalid.

Using a Custom Disk
-------------------

[](#using-a-custom-disk)

By default, this package's service provider will register a `page-cache` local disk that just points to `storage_path('app/public/page-cache')`. You can change this behavior by adding your own `page-cache` disk to `filesystems.php`.

I'll update this section once I've tested this myself, but you could use this to store cached pages on cloud storage, and then use multi source CDN to check that cloud storage for cached files, and only make requests to your web server if its not found. This might be possible with Fastly using [Multiple Backends](https://docs.fastly.com/en/guides/checking-multiple-backends-for-a-single-request) and [URL Rewrites](https://developer.fastly.com/solutions/recipes/rewrite-url-path).

Console Commands
----------------

[](#console-commands)

### Clearing Page Cache

[](#clearing-page-cache)

Clear your entire page cache using `php artisan page-cache:clear`. You can also recrawl your site to warm the cache using the `--touch` option.

### Refreshing Pages

[](#refreshing-pages)

Refresh every page on your site using `php artisan page-cache:refresh`. This will just go through all existing cached pages and refresh any that have changed.

### Installation Instructions

[](#installation-instructions)

Run `php arisan page-cache:install:apache` for PHP installation instructions or `php artisan page-cache:install:nginx` for Nginx installation instructions.

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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

Total

4

Last Release

1894d ago

### Community

Maintainers

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

---

Top Contributors

[![gregpriday](https://avatars.githubusercontent.com/u/1126859?v=4)](https://github.com/gregpriday "gregpriday (56 commits)")[![JosephSilber](https://avatars.githubusercontent.com/u/1403741?v=4)](https://github.com/JosephSilber "JosephSilber (46 commits)")[![vkazakevich](https://avatars.githubusercontent.com/u/9676524?v=4)](https://github.com/vkazakevich "vkazakevich (16 commits)")[![mvdnbrk](https://avatars.githubusercontent.com/u/802681?v=4)](https://github.com/mvdnbrk "mvdnbrk (7 commits)")[![KodeStar](https://avatars.githubusercontent.com/u/5698566?v=4)](https://github.com/KodeStar "KodeStar (1 commits)")[![irineujunior](https://avatars.githubusercontent.com/u/260451?v=4)](https://github.com/irineujunior "irineujunior (1 commits)")[![andypa](https://avatars.githubusercontent.com/u/148700?v=4)](https://github.com/andypa "andypa (1 commits)")[![thijsvdanker](https://avatars.githubusercontent.com/u/429548?v=4)](https://github.com/thijsvdanker "thijsvdanker (1 commits)")

---

Tags

laravelcache

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[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)[arifhp86/laravel-clear-expired-cache-file

Remove laravel expired cache file/folder

36128.7k](/packages/arifhp86-laravel-clear-expired-cache-file)[byerikas/cache-tags

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

1413.9k](/packages/byerikas-cache-tags)[salehhashemi/laravel-configurable-cache

Configurable Laravel cache manager

2114.5k1](/packages/salehhashemi-laravel-configurable-cache)

PHPackages © 2026

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