Skip to content

Instantly share code, notes, and snippets.

@zackify
Last active August 29, 2015 13:58
Show Gist options
  • Save zackify/9927434 to your computer and use it in GitHub Desktop.
Save zackify/9927434 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