method output documentation in bbn\Cdn
function()
{
$file = empty($this->cfg['file']) || $this->cfg['is_component'] ? $this->cfg['cache_file'] : $this->fpath . $this->cfg['file'];
if ($file && is_file($file)) {
// get the HTTP_IF_MODIFIED_SINCE header if set
$client_if_modified = $_SERVER['HTTP_IF_MODIFIED_SINCE'] ?? false;
// get the HTTP_IF_NONE_MATCH header if set (etag: unique file hash)
$client_tag = isset($_SERVER['HTTP_IF_NONE_MATCH']) ? trim(str_replace('"', '', Stripslashes($_SERVER['HTTP_IF_NONE_MATCH']))) : false;
// We get a unique hash of this file (etag)
$file_tag = md5($file . $this->file_mtime);
//die(var_dump($this->file_mtime, $client_tag, $etagFile, $client_if_modified, $_SERVER));
if ($this->mode === 'css') {
header('Content-type: text/css; charset=utf-8');
}
else {
if ($this->mode === 'js') {
header('Content-type: text/javascript; charset=utf-8');
}
else {
$mime = finfo_open(FILEINFO_MIME_TYPE);
header('Content-type: ' . finfo_file($mime, $file));
}
}
// make sure caching is turned on
header('Cache-Control: max-age=14400');
header('Expires: ' . gmdate('D, d M Y H:i:s', Time() + 14400) . ' GMT');
// set last-modified header
header('Date: ' . gmdate('D, d M Y H:i:s', $this->file_mtime) . ' GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $this->file_mtime) . ' GMT');
// set etag-header
header("ETag: $file_tag");
//header('Pragma: public');
// check if page has changed. If not, send 304 and exit
if (
$client_if_modified
&& ((strtotime($client_if_modified) == $this->file_mtime)
|| ($client_tag == $file_tag) )
) {
header('HTTP/1.1 304 Not Modified');
}
else {
if (
empty($this->cfg['file']) && (($this->mode === 'js')
|| ($this->mode === 'css') )
) {
if (
isset($_SERVER['HTTP_ACCEPT_ENCODING'])
&& (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false)
) {
header('Content-Encoding: gzip');
$file .= '.gzip';
}
}
readfile($file);
}
exit();
}
throw new \Exception('No cache file ' . $file);
}
BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way
This website uses cookies to ensure you get the best experience on our website.
© 2011-2025
BBN Solutions