WebsiteBaker Logo
  • *
  • Templates
  • Help
  • Add-ons
  • Download
  • Home
*
Welcome, Guest. Please login or register.

Login with username, password and session length
 

News


WebsiteBaker 2.13.6 is now available!


Will it continue with WB? It goes on! | Geht es mit WB weiter? Es geht weiter!
https://forum.websitebaker.org/index.php/topic,32340.msg226702.html#msg226702


The forum email address board@websitebaker.org is working again
https://forum.websitebaker.org/index.php/topic,32358.0.html


R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WB
https://forum.websitebaker.org/index.php/topic,32355.0.html


* Support WebsiteBaker


  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.10.x) »
  • General Help & Support »
  • cache wb site on server?
  • Print
Pages: [1]   Go Down

Author Topic: cache wb site on server?  (Read 15705 times)

johnbroeckaert

  • Guest
cache wb site on server?
« on: February 07, 2018, 08:17:53 AM »
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: [Select]
## 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
Logged

Offline evaki

  • Posts: 2810
Re: cache wb site on server?
« Reply #1 on: February 07, 2018, 09:44:20 AM »
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: [Select]
<?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();  
?>

Example: CMS in root/cms static file in root
MfG. Evaki
« Last Edit: February 07, 2018, 09:53:29 AM by evaki »
Logged

johnbroeckaert

  • Guest
Re: cache wb site on server?
« Reply #2 on: February 07, 2018, 10:16:37 AM »
@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?
Logged

Offline evaki

  • Posts: 2810
Re: cache wb site on server?
« Reply #3 on: February 07, 2018, 10:30:57 AM »
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
Logged

Offline jacobi22

  • Betatester
  • **
  • Posts: 5920
Re: cache wb site on server?
« Reply #4 on: February 07, 2018, 10:37:30 AM »
i use this solution here for a while, works for me without problems

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

Offline evaki

  • Posts: 2810
Re: cache wb site on server?
« Reply #5 on: February 07, 2018, 11:01:07 AM »
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
Logged

johnbroeckaert

  • Guest
Re: cache wb site on server?
« Reply #6 on: February 07, 2018, 11:21:13 AM »
Thank you both @jacobi22 and @evaki.

I'm testing  :-D
Logged

  • Print
Pages: [1]   Go Up
  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.10.x) »
  • General Help & Support »
  • cache wb site on server?
 

  • SMF 2.0.19 | SMF © 2017, Simple Machines
  • XHTML
  • RSS
  • WAP2