/** 删除缓存,如果$key没有值 将清空所有缓存 */ function delete($key = null) { if ($key) { $a = $this->file($key); if (file_exists($a[0])) { unlink($a[0]); } if (file_exists($a[1])) { unlink($a[1]); } } else { File::rmdir($this->path); } }
<?php $storage = new \Core\Storage(); $storage->sync(); if (isset($_GET['url']) && is_file($_GET['url'])) { // For images and that kind of stuff $file = $_GET['url']; $ext = \Core\File::getExtension($file); switch ($ext) { case 'css': case 'js': header("Content-Type: " . \Core\File::getMime(strtolower(pathinfo($file, PATHINFO_EXTENSION)))); header('Content-Length: ' . filesize($file)); if ($storage->get('CORE.static_client_cache')) { $offset = $storage->get('CORE.static_client_cache_time'); header("Expires: " . gmdate("D, d M Y H:i:s", time() + $offset) . " GMT"); header("Cache-Control: max-age={$offset}, must-revalidate"); } // Minify $content = file_get_contents($file); $buffer = preg_replace('!/\\*[^*]*\\*+([^/][^*]*\\*+)*/!', '', $content); $buffer = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $content); echo $buffer; die; break; } } $router = new \Core\Router\Router($_GET['url']); $router->on404 = function () { echo '404, no route found.'; };