Skip to content

Instantly share code, notes, and snippets.

@paramonovav
Forked from zackify/filters.php
Last active August 29, 2015 14:26
Show Gist options
  • Save paramonovav/cdad5f124d09d2179a28 to your computer and use it in GitHub Desktop.
Save paramonovav/cdad5f124d09d2179a28 to your computer and use it in GitHub Desktop.
Cache Everything in laravel with 4 extra lines of code!
App::before(function($request)
{
$key = Str::slug($request->url());
if(Cache::has($key)) return Cache::get($key);
});
App::after(function($request, $response)
{
$key = Str::slug($request->url());
if( ! Cache::has($key)) Cache::put($key, $response->getContent(),Config::get('cache.time'));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment