New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

barryvdh/laravel-httpcache

HttpCache for Laravel
417,200 501

Larablocks Analysis

Compatibility

Trusted maintainer

barryvdh/laravel-httpcache works with Laravel 9 to 13 (latest release v1.0.3, Feb 27, 2026).

Laravel 4 to 8 in earlier releases.

  • Trusted maintainer: barryvdh publishes 9 packages on Larablocks, with 21,686,123 downloads a month between them.

Recommendation checks

Solid choice

Solid choice: maintained and up to date, meets 3 of 4 checks; below the bar for Recommended on use.

  • Works with Laravel 13, the current version
  • Released in the last 12 months (Feb 27, 2026)
  • 3,113 downloads a month (needs 10,000)
  • 501 GitHub stars (at least 100)

State

Maintained
  • Last stable release: Feb 27, 2026.
  • 1 release in the last 12 months.
  • First released: Feb 6, 2014.
  • Monthly downloads: 3,113, up 92% from six months ago.
  • 23 open issues on GitHub.

Data from Packagist and GitHub, checked by Larablocks on Dec 1, 2026.

Install
composer require barryvdh/laravel-httpcache
Latest Version:v1.0.3
PHP:^8
Laravel:9 – 13
Older releases:4 – 8
License:MIT
Last Updated:Jul 8, 2026
Links: GitHub  ·  Packagist
Maintainer: barryvdh

HttpCache for Laravel

Tests Packagist License Latest Stable Version Total Downloads Fruitcake

Laravel can use HttpKernelInterface Middlewares, so also HttpCache. This package provides a simple ServiceProvider to get you started with HttpCache.

First, require this package with composer

composer require barryvdh/laravel-httpcache

After updating, add the ServiceProvider to the array of providers in app/config/app.php

'Barryvdh\HttpCache\ServiceProvider',

You can now add the Middleware to your Kernel:

'Barryvdh\HttpCache\Middleware\CacheRequests',

Caching is now enabled, for public responses. Just set the Ttl or MaxSharedAge

Route::get('my-page', function(){
   return Response::make('Hello!')->setTtl(60); // Cache 1 minute
});

You can use the provided SetTtl middleware in your Kernel to simplify this:

protected $routeMiddleware = [
    // ...
    'ttl' => \Barryvdh\HttpCache\Middleware\SetTtl::class,
];

Route::get('my-page', function(){
   return 'Hello' 
})->middleware('ttl:60'); // Cache 1 minute

Publish the config to change some options (cache dir, default ttl, etc) or enable ESI.

$ php artisan vendor:publish --provider="Barryvdh\HttpCache\ServiceProvider"

Direct approach, without ServiceProvider

Note: This is still in beta, test with caution. It should be faster, but less flexible because it starts earlier.

You can also wrap the Kernel in the HttpCache, in your public/index.php. Replace the 'Run The Application' part like this:

$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);

$kernel = \Barryvdh\HttpCache\CacheKernel::wrap($kernel);

$response = $kernel->handle(
    $request = Illuminate\Http\Request::capture()
);

$response->send();

$kernel->terminate($request, $response);

ESI

Enable ESI in your config file and add the Esi Middleware to your Kernel:

'Barryvdh\HttpCache\Middleware\ParseEsi',

You can now define ESI includes in your layouts.

<esi:include src="<?= url('partial/page') ?>"/>

This will render partial/page, with it's own TTL. The rest of the page will remain cached (using it's own TTL)

Purging/flushing the cache

You can purge a single url or just delete the entire cache directory:

App::make('http_cache.store')->purge($url);
\File::cleanDirectory(app('http_cache.cache_dir'));

Or use the Artisan httpcache:clear command

$ php artisan httpcache:clear

More information

For more information, read the Docs on Symfony HttpCache

Related Packages

bunkuris/has-cache

HasCache trait for Laravel models with cache key managers

3,704 0
silber/page-cache

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

537,204 1,260
laracasts/matryoshka

Russian Doll Caching for Laravel.

61,021 237
geekcache/geekcache

A wrapper for Memcached with tags, soft invalidation, memoization, and regenerat...

38,973 6
mitydigital/statamic-scheduled-cache-invalidator

A command to help invalidate the cache when scheduled Statamic entries are due t...

35,748 3

Version History

Version Released PHP Laravel License
v1.0.3 ^8 ^9|^10|^11.0|^12.0|^13.0 MIT
v1.0.2 ^8 ^9|^10|^11.0|^12.0 MIT
v1.0.1 ^8 ^9|^10|^11.0 MIT
v1.0.0 ^8 ^9|^10 MIT
v0.3.10 >=7.2 ^6|^7|^8|^9 MIT