I reference "manifest.php" instead of "cache.manifest", then my php file looks like this:
<?php
header('Content-Type: text/cache-manifest');
echo "CACHE MANIFEST
";
$hashes = "";
$dir = new RecursiveDirectoryIterator(".");
foreach(new RecursiveIteratorIterator($dir) as $file) {
$info = pathinfo($file);
if ($file->IsFile() &&
$file != "./manifest.php" &&
substr($file->getFilename(), 0, 1) != ".")
{
echo $file . "
";
$hashes .= md5_file($file);
}
}
echo "# Hash: " . md5($hashes) . "
";
?>
The file hashes keep it up-to-date so that if any files change the manifest changes as well. Hope that helps :)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…