PHP code example of socalnick / scn-http-cache

1. Go to this page and download the library: Download socalnick/scn-http-cache 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/ */

    

socalnick / scn-http-cache example snippets



return array(
    'modules' => array(
        'Application',
        'ScnHttpCache',
    ),
    'module_listener_options' => array(
        'config_glob_paths'    => array(
            'config/autoload/{,*.}{global,local}.php',
        ),
        'module_paths' => array(
            './module',
            './vendor',
        ),
    ),
);

public function recentTweetsAction()
{
    $headers = $this->getResponse()->getHeaders();
    $cacheControl = new \Zend\Http\Header\CacheControl();
    $cacheControl->addDirective('s-maxage', '10');
    $headers->addHeader($cacheControl);

    $viewModel = new ViewModel();
    $viewModel->setTerminal(true);

    return $viewModel;
}

<div> echo $this->esi($this->url('route/to/recent/tweets')) 

<ul>
    <li> echo date('h:i:s')