1. Go to this page and download the library: Download tschueller/simplephpcache 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/ */
tschueller / simplephpcache example snippets
use Tschueller\SimplePhpCache\SimplePhpCache;
Set the cache base directory (les are stored below `<cacheBaseDir>/.simplePhpCache`. To
use an existing application-owned cache directory name, configure one safe
directory name before using the cache:
SimplePhpCache::$cacheDirectoryName = ".cache";
The default remains `.simplePhpCache`. The directory name may contain letters,
numbers, dots, hyphens, and underscores, but no path separators, spaces, empty
value, or the path segments `.` and `..`.
Optionally set a namespace to keep cache entries for several applications or
tenants separate below the same base directory:
SimplePhpCache::$cacheNamespace = "customer-a";
If no cache base directory is configured, SimplePhpCache temporarily falls back
to the system temporary directory for backward compatibility. This emits an
`E_USER_DEPRECATED` warning once per request and will be removed in version 2.0.
Set an application-owned directory outside the web root. Standard PHP error
configuration controls whether this warning is displayed or logged; for example,
exclude `E_USER_DEPRECATED` from `error_reporting` to suppress it.
Set the max cache time in seconds (Optional, default is 86400 (1 day)):
SimplePhpCache::$maxCacheTime = 3600; // 1h
Cache HTML
----------
$cacheName = "html_cache_1";
if (SimplePhpCache::initHTMLCaching($cacheName)) {