PHP code example of zfcampus / zf-http-cache

1. Go to this page and download the library: Download zfcampus/zf-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/ */

    

zfcampus / zf-http-cache example snippets


return [
    /* ... */
    'modules' => [
        /* ... */
        'ZF\HttpCache',
    ],
    /* ... */
];

// See `config/module.config.php` for a complete commented example
'zf-http-cache' => [
    /* ... */
    'controllers' => [
        '<controller>' => [
            '<http-method>'  => [
                '<cache-header-name>' => [
                    'override' => true,
                    'value'    => '<cache-header-value>',
                ],
            ],
        ],
    ],
    /* ... */
],    

'zf-http-cache' => [
    /* ... */
    'enable' => true, // Cache module is enabled.
    /* ... */
],

'zf-http-cache' => [
    /* ... */
    'http_codes_black_list' => ['201', '304', '400', '500'], // Whatever the other configurations, the responses with these HTTP codes won't be cached.
    /* ... */
],

'zf-http-cache' => [
    /* ... */
    'regex_delimiter' => '~',
    /* ... */
    'controllers' => [
        '~.*~' => [ // Acts as a wildcard.
            /* ... */
        ],
    ],
    /* ... */
],

'service_manager' => [
    'factories' => [
        'ZF\HttpCache\HttpCacheListener' => 'ZF\HttpCache\HttpCacheListenerFactory',
    ],
],