예제 #1
0
 *
 * It's useful to have settings defined in one file, to avoid repeating yourself
 *
 */
require_once __DIR__ . '/../vendor/autoload.php';
//PageCache configuration in a file
$config_file = __DIR__ . '/conf.php';
//pass config file
$cache = new PageCache\PageCache($config_file);
//enable log, by default disabled in conf.php
$cache->enableLog();
//getfilepath
echo 'Cache filepath, getFilePath(): ' . $cache->getFilePath() . '<br/>';
echo '<hr/>';
//get file name
echo 'Cache file name, getFile(): ' . $cache->getFile();
echo '<hr>';
//cache present already?
echo 'isChached(): ';
if ($cache->isCached()) {
    echo 'cache exists';
} else {
    echo 'cache does not exist';
}
echo '<hr>';
//get cache file contents
echo 'Cache file contents: <br/>';
$str = $cache->getPageCache();
var_dump($str);
echo '<hr/>';
//Clear cache for this page
        <button type="submit">Set $_SESSION['excl'] = 555</button>
    </form>

    <br class="clear"/><br/>
    <code>PageCache call demo: $cache->sessionExclude(array('excl'));</code>
</fieldset>


<?php 
/**
 * Print session data if present
 */
if (isset($_SESSION['excl'])) {
    var_dump($_SESSION);
}
echo '<br><b>Generated cache file name: </b><fieldset>' . $cache->getFile() . '</fieldset>';
?>

<br>
<h3 style="color: red">This is a Session Exclude demo PageCache page that is going to be cached.</h3>
<h3>Default cache expiration time for this page is 20 minutes. You can change this value in your <i>conf.php</i>
    and passing its file path to PageCache constructor, or by calling <i>setExpiration()</i> method.</h3>
<h3 style="color: green;">This is a dynamic PHP <i>date('H:i:s')</i>
    call, note that time doesn't change on refresh: <?php 
echo date('H:i:s');
?>
.</h3>
<br>
<h4>Check examples/cache/ directory to see cached content.
    Erase this file to regenerate cache, or it will automatically be regenerated in 20 minutes.</h4>
</body>