cache wb site on server?

johnbroeckaert

Thank you both @jacobi22 and @evaki.

I'm testing  :-D

evaki

Jo. isn -wenn man so will- Mix (Idee) aus der "ganz alten" und der "neuen" vorgestellten Version. Jedenfalls kann er ein wenig experimentieren. Vielleicht reicht ja das ein oder andere.

Wer mehr will, muß halt "richtige" Kontrollstrukturen einbauen, was einen nicht unerheblichen Mehraufwand mit sich bringt, und je nach CMS, heutzutage nicht mehr so leicht "wie früher" umzusetzen ist. (Hab' mal ein wenig in einigen reingeschaut)
MfG. Evaki

Gast


evaki

Hi.
>>I guess turning it off is just remove the code from the template?
Yes,
but the generated static files have to be deleted manually. (FTP)
>>...know the METRICS script
No

............Am gone again -work
MfG. Evaki

johnbroeckaert

@evaki
Thanks.
I wiil test your code today.
I guess turning it off is just remove the code from the template?
Do you by any chance know the METRICS script witch goes in the .htaccces file?

evaki

#2
Hi,
"Sandkasten" 08.Jan.2018 - One of ???
Source without control structures (on/off)
I don't know if any of this is working, (experimental status)

<?php
//"Sandkasten" 08.Jan.2018
//Template cache for static files
$url $_SERVER["SCRIPT_NAME"];
$break Explode('/'$url);
$file $break[count($break) - 1];
//$cachefile =$_SERVER['DOCUMENT_ROOT'].PAGES_DIRECTORY.'/'. 'iscached-'.substr_replace($file ,"",-4).'.html';
$cachefile =$_SERVER['DOCUMENT_ROOT'].PAGES_DIRECTORY.'/'''.substr_replace($file ,"",-4).'.html';
//$cachefile =$_SERVER['DOCUMENT_ROOT'].'/'. 'iscached-'.substr_replace($file ,"",-4).'.html';
//$cachefile =$_SERVER['DOCUMENT_ROOT'].'/'. ''.substr_replace($file ,"",-4).'.htm';

$cachetime 18000;
// Serve from the cache if it is younger than $cachetime
if (file_exists($cachefile) && time() - $cachetime filemtime($cachefile)) {
    echo 
"<!-- Cached copy, generated ".date('H:i'filemtime($cachefile))." -->\n";
    include(
$cachefile);
    exit;
}
ob_start();
?>

<html>
<body>
..............................
</body>
</html>
<?php
$fp 
fopen($cachefile'w');
fwrite($fpob_get_contents());
fclose($fp);
ob_end_flush();  
?>


Example: CMS in root/cms static file in root
MfG. Evaki

johnbroeckaert

Hi all,

I try to use the smartest way to make a site cache on the server. I know there is a cache script that requires me to change something in the index.php, but I can not find that script in the forum anymore. @evaki recently published a kind of cache that stood in the 'sandbox' with them. Is it still up-to-date?
I found the code below at METRICS. Is that just usable in a .htaccess file?

## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 2 days"
</IfModule>
## EXPIRES CACHING ##


What would be the smartes way?
Thanks