2017 © Pedro Peláez
 

library laravel-httpcache

HttpCache for Laravel 5

image

shawnley/laravel-httpcache

HttpCache for Laravel 5

  • Monday, June 29, 2015
  • by Shawnley
  • Repository
  • 1 Watchers
  • 0 Stars
  • 732 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 24 Forks
  • 0 Open issues
  • 10 Versions
  • 0 % Grown

The README.md

HttpCache for Laravel 5

For Laravel 4.1+, require v0.1.x

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

First, require this package in composer.json and run composer update, (*2)

"barryvdh/laravel-httpcache": "0.2.x@dev"

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

'Barryvdh\HttpCache\ServiceProvider',

You can now add the Middleware to your Kernel:, (*4)

'Barryvdh\HttpCache\Middleware\CacheRequests',

Caching is now enabled, for public responses. Just set the Ttl or MaxSharedAge, (*5)

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

You can also define a filter., (*6)

Route::filter('cache', function($route, $request, $response, $age=60){
    $response->setTtl($age);
});
Route::get('cached', array('after' => 'cache:30', function(){
    return 'I am cached 30 seconds!';
}));

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

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

ESI

Enable ESI in your config file and add the Esi Middleware to your Kernel:, (*8)

'Barryvdh\HttpCache\Middleware\ParseEsi',

You can now define ESI includes in your layouts., (*9)

<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), (*10)

Purging/flushing the cache

You can purge a single url or just delete the entire cache directory:, (*11)

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

Or use the Artisan httpcache:clear command, (*12)

$ php artisan httpcache:clear

More information

For more information, read the Docs on Symfony HttpCache, (*13)

The Versions

29/06 2015

dev-master

9999999-dev

HttpCache for Laravel 5

  Sources   Download

MIT

The Requires

 

laravel cache esi httpcache

29/06 2015

0.2.5

0.2.5.0

HttpCache for Laravel 5

  Sources   Download

MIT

The Requires

 

laravel cache esi httpcache

29/06 2015

dev-patch-1

dev-patch-1

HttpCache for Laravel 5

  Sources   Download

MIT

The Requires

 

laravel cache esi httpcache

29/06 2015

0.2.4

0.2.4.0

HttpCache for Laravel 5

  Sources   Download

MIT

The Requires

 

laravel cache esi httpcache

02/06 2015

v0.2.1

0.2.1.0

HttpCache for Laravel 5

  Sources   Download

MIT

The Requires

 

laravel cache esi httpcache

02/06 2015

v0.2.2

0.2.2.0

HttpCache for Laravel 5

  Sources   Download

MIT

The Requires

 

laravel cache esi httpcache

02/06 2015

0.2.3

0.2.3.0

HttpCache for Laravel 5

  Sources   Download

MIT

The Requires

 

laravel cache esi httpcache

18/02 2015

v0.2.0

0.2.0.0

HttpCache for Laravel 5

  Sources   Download

MIT

The Requires

 

laravel cache esi httpcache

27/04 2014

v0.1.1

0.1.1.0

HttpCache for Laravel 4.1

  Sources   Download

MIT

The Requires

 

laravel cache esi httpcache

06/02 2014

v0.1

0.1.0.0

HttpCache for Laravel 4.1

  Sources   Download

MIT

The Requires

 

laravel cache esi httpcache