PHP code example of volkerschulz / file-cache

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

    

volkerschulz / file-cache example snippets


use volkerschulz\FileCache;

// Create instance 
$filecache = new FileCache('testfiles/cache.png');

// Respond to request
$filecache->respond();

use volkerschulz\FileCache;

// Create instance for file 'testfiles/utf.json' 
// with default options
$filecache = new FileCache('testfiles/utf.json');

// Set additional custom headers (optional)
$filecache->addHeader('Content-Type', 'application/json; charset=UTF8');

// Respond to request
$filecache->respond();

use volkerschulz\FileCache;

$options = [
    'use_checksum'  => true,
    'hash_algo'     => 'xxh128',
    'fresh_for'     => 300
];

// Create instance for file 'testfiles/utf.json' 
// with custom options
$filecache = new FileCache('testfiles/utf.json', $options);

// Set additional custom headers (optional)
$filecache->addHeader('Content-Type', 'application/json; charset=UTF8');

// Respond to request
$filecache->respond();