How to not cache a php file where a cachemanifest is beeing called?
Posted
by Volmar
on Stack Overflow
See other posts from Stack Overflow
or by Volmar
Published on 2010-04-12T20:47:55Z
Indexed on
2010/04/12
20:53 UTC
Read the original article
Hit count: 275
Hi,
i'm building a iphone app with jqtouch and i use a cachemanifest to cache all the static files (images, css, javascript) to make it load faster. However the page uses php for the dynamic content and i don't want to cache that. So i'm generating the cachemanifest with this php-script(manifest.php):
<?php
header('Content-Type: text/cache-manifest');
echo "CACHE MANIFEST\n";
$hashes = "";
$lastFileWasDynamic = FALSE;
$dir = new RecursiveDirectoryIterator(".");
foreach(new RecursiveIteratorIterator($dir) as $file) {
if ($file->IsFile() && $file != "./manifest.php" &&
substr($file->getFilename(), 0, 1) != ".") {
if(preg_match('/.php$/', $file)) {
if(!$lastFileWasDynamic) {
echo "\n\nNETWORK:\n";
}
$lastFileWasDynamic = TRUE;
} else {
if($lastFileWasDynamic) {
echo "\n\nCACHE:\n";
$lastFileWasDynamic = FALSE;
}
}
echo $file . "\n";
$hashes .= md5_file($file);
}
}
echo "\nNETWORK:\nhttp://chart.apis.google.com/\n\n# Hash: " . md5($hashes) . "\n";
?>
This actually works really good except for one irritating thing:
From what i read somewhere the file that calls the cachemanifest is automaticly included in the manifest and is beeing cached. Wich means that my start-page index.php, where i call the cachemanifest is beeing cached. This leads to very irritating problems.
is there any way to deal with this or any smart workaround? The page is in the cachemanifest listed as NETWORK, but it looks like this is beeing overruled by the fact that the cachemanifest is called from the file.
© Stack Overflow or respective owner