PHPackages                             mnshankar/laravel-cache-route - 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. mnshankar/laravel-cache-route

ActiveLibrary[Caching](/categories/caching)

mnshankar/laravel-cache-route
=============================

Cache (HTML) output of entire route to speedup your Laravel application

v1.0(8y ago)1911MITPHPPHP &gt;=5.4.0

Since May 26Pushed 8y ago1 watchersCompare

[ Source](https://github.com/mnshankar/laravel-cache-route)[ Packagist](https://packagist.org/packages/mnshankar/laravel-cache-route)[ RSS](/packages/mnshankar-laravel-cache-route/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

Cache contents of entire route in Laravel
=========================================

[](#cache-contents-of-entire-route-in-laravel)

This is a Laravel 5.0+/PHP 5.4+ package that caches the response to an entire "get" request in the cache so subsequent requests to the same url are speeded up substantially.

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

[](#installation)

Every effort has been made to insure that the package is extremely easy to install and use. After you "require" the package, you are ready to use it! There is no need for setting up service providers, facades, config files etc.

```
$ composer require mnshankar/laravel-cache-route
```

Usage
-----

[](#usage)

Edit your http kernel.php file to include the package like so:

```
'cache.route'=>'mnshankar\Cache\Middleware\CacheRoute',
```

Now, use the middleware to cache the HTML output of an entire page either from the controller or from your route like so:

1. In your controller:

    ```
    function __construct()
    {
        $this->middleware('cache.route');
    }
    ```
2. In your route:

    Using Laravel 5.0

    ```
    Route::get('my/page', ['middleware' => 'cache-route', function()
    {
        //
    }]);
    ```

    Using Laravel 5.1+

    You can continue using Laravel 5.0 style.. or use chaining:

    ```
    Route::get('/', function () {
        //
    })->middleware(['cache-route']);
    ```

    You may also use route groups. Please look up Laravel documentation on Middleware to learn more

Configuration Options
---------------------

[](#configuration-options)

Two configuration options (set via env parameters) are used by the package

1. Cache TTL (Time-To-Live):

    CACHE\_TTL=30

    This parameter specifies a cache ttl value of 30 minutes

    Note that you can always use php artisan cache:flush to clear your application cache
2. Enable Cache (defaults to true):

    CACHE\_ENABLE=false

    This parameter can be used to turn off caching

Thoughts
--------

[](#thoughts)

Be VERY cautions when using a whole page cache such as this. Remember contents of the cache are visible to ALL your users.

1. For, "mostly static" content, go for it!
2. For, "mostly dynamic" content or heavily user-customized content, AVOID this strategy. User specific information is gathered server side. So, you essentially WANT to hit the server.

**Good rule of thumb**: If two different users see different pages on hitting the same URL, DO NOT cache the output using this strategy. An alternative may be to cache database queries.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

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

Unknown

Total

1

Last Release

3275d ago

### Community

Maintainers

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

---

Top Contributors

[![mnshankar](https://avatars.githubusercontent.com/u/2873887?v=4)](https://github.com/mnshankar "mnshankar (3 commits)")

### Embed Badge

![Health badge](/badges/mnshankar-laravel-cache-route/health.svg)

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

###  Alternatives

[spatie/laravel-responsecache

Speed up a Laravel application by caching the entire response

2.8k8.2M51](/packages/spatie-laravel-responsecache)[genealabs/laravel-model-caching

Automatic caching for Eloquent models.

2.4k4.8M26](/packages/genealabs-laravel-model-caching)[mikebronner/laravel-model-caching

Automatic caching for Eloquent models.

2.4k127.1k1](/packages/mikebronner-laravel-model-caching)[illuminate/cache

The Illuminate Cache package.

12835.6M1.4k](/packages/illuminate-cache)[laragear/cache-query

Remember your query results using only one method. Yes, only one.

272122.8k](/packages/laragear-cache-query)[namoshek/laravel-redis-sentinel

An extension of Laravels Redis driver which supports connecting to a Redis master through Redis Sentinel.

38679.0k](/packages/namoshek-laravel-redis-sentinel)

PHPackages © 2026

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