barryvdh/laravel-httpcache
Larablocks Analysis
Compatibility
Trusted maintainerbarryvdh/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 choiceSolid 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 |
HttpCache for Laravel
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
Caches responses as static files on disk for lightning fast page loads.
A wrapper for Memcached with tags, soft invalidation, memoization, and regenerat...
A command to help invalidate the cache when scheduled Statamic entries are due t...
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| v1.0.3 | ^8 | ^9| | MIT | |
| v1.0.2 | ^8 | ^9| | MIT | |
| v1.0.1 | ^8 | ^9| | MIT | |
| v1.0.0 | ^8 | ^9| | MIT | |
| v0.3.10 | >=7.2 | ^6| | MIT | |
| v0.3.9 | >=5.5 | ^5.5| | MIT | |
| v0.3.8 | >=5.5 | ^5.5| | MIT | |
| v0.3.7 | >=5.5 | ^5.5| | MIT | |
| v0.3.6 | >=5.5 | 5.5.x| | MIT | |
| v0.3.5 | >=5.5 | 5.5.x| | MIT | |
| v0.3.4 | >=5.5 | 5.5.x| | MIT | |
| v0.3.3 | >=5.5 | 5.5.x| | MIT | |
| v0.3.2 | >=5.5 | 5.1.x| | MIT | |
| v0.3.1 | >=5.5 | 5.1.x| | MIT | |
| v0.3.0 | >=5.5 | 5.1.x| | MIT | |
| v0.2.7 | >=5.5 | 5.1.x| | MIT | |
| v0.2.6 | >=5.5 | 5.1.x| | MIT | |
| v0.2.5 | >=5.4.0 | 5.0.x| | MIT | |
| v0.2.4 | >=5.4.0 | 5.0.x| | MIT | |
| v0.2.3 | >=5.4.0 | 5.0.x| | MIT | |
| v0.2.2 | >=5.4.0 | 5.0.x| | MIT | |
| v0.2.1 | >=5.4.0 | 5.0.x| | MIT | |
| v0.2.0 | >=5.4.0 | 5.0.x | MIT | |
| v0.1.1 | >=5.3.0 | ~4.1 | MIT | |
| v0.1 | >=5.3.0 | 4.1.x | MIT |


