WebsiteBaker Support (2.10.x) > General Help & Support

cache wb site on server?

(1/2) > >>

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?


--- Code: ---## 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 ##
--- End code ---

What would be the smartes way?
Thanks

evaki:
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)

--- Code: ---<?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($fp, ob_get_contents());
fclose($fp);
ob_end_flush();  
?>

--- End code ---
Example: CMS in root/cms static file in root
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:
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

Gast:
i use this solution here for a while, works for me without problems

https://forum.WebsiteBaker.org/index.php/topic,28202.msg203218.html#msg203218

Navigation

[0] Message Index

[#] Next page

Go to full version