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

Your donations will help to:

  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!

You can donate by clicking on the button below.


  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • General Community »
  • Global WebsiteBaker 2.8.x discussion »
  • Cache system
  • Print
Pages: [1]   Go Down

Author Topic: Cache system  (Read 5220 times)

Offline Xagone

  • Posts: 482
  • Gender: Male
  • Developper
    • Xagone Inc
Cache system
« on: July 23, 2010, 10:24:40 PM »
I've done a little cache system for my website in the template index.php, it work in a way that it takes ~25% less time for my server to send the html...
but i'd like a true cache system on WSB.

here's what i've done :
in my index.php
at the absolute beginining of the file (before ANYTHING)
Code: [Select]
<?php
// Include the WB functions file
require_once(WB_PATH.&#39;/framework/functions.php&#39;);
if(file_exists(WB_PATH.&#39;/temp/&#39;.page_filename($_SERVER[&#39;REQUEST_URI&#39;]).&#39;.tmp&#39;) &&
filemtime(WB_PATH.&#39;/temp/&#39;.page_filename($_SERVER[&#39;REQUEST_URI&#39;]).&#39;.tmp&#39;) >= (time()-86400)) {
#header(&#39;HTTP/1.1 304 Not Modified&#39;);
exit(file_get_contents(WB_PATH.&#39;/temp/&#39;.page_filename($_SERVER[&#39;REQUEST_URI&#39;]).&#39;.tmp&#39;));
} else {
ob_start(&#39;cache_temp&#39;);
?>
and not at the absolute end :
Code: [Select]
<?php 
ob_end_flush
();
}
function 
cache_temp($buffer) {
file_put_contents(WB_PATH.&#39;/temp/&#39;.page_filename($_SERVER[&#39;REQUEST_URI&#39;]).&#39;.tmp&#39;,$buffer);
return $buffer;
}
?>

it's a 24h cache, cause my site dont change that much, but you can play with it by changing the "86400" to something else like :
6 hours = 21600
1 hour = 3600
10 min : 600
Logged
Xagone Inc. (formerly VotreEspace)
http://xagone.com/

Offline Xagone

  • Posts: 482
  • Gender: Male
  • Developper
    • Xagone Inc
Re: Cache system
« Reply #1 on: July 26, 2010, 08:33:20 PM »
so many ppl tried to hack my cache, so funny!
Logged
Xagone Inc. (formerly VotreEspace)
http://xagone.com/

  • Print
Pages: [1]   Go Up
  • WebsiteBaker Community Forum »
  • General Community »
  • Global WebsiteBaker 2.8.x discussion »
  • Cache system
 

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