PHP code example of shawnley / laravel-httpcache

1. Go to this page and download the library: Download shawnley/laravel-httpcache library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

shawnley / laravel-httpcache example snippets


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

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!';
}));

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