Welcome, Guest. Please login or register.
Did you miss your activation email?
February 11, 2012, 09:13:08 PM

Login with username, password and session length
Search:     Advanced search
Wollen Sie dem WebsiteBaker Team beitreten?
Nähere Informationen finden Sie unter hier und auf unserer neuen Webseite.
149586 Posts in 21094 Topics by 7537 Members
Latest Member: Wukky
* Home Help Search Login Register
Pages: [1]   Go Down
Print
Author Topic: Caching system  (Read 414 times)
smsoft

Offline Offline

Posts: 4


« on: October 05, 2011, 09:41:10 AM »

Hi to all,
There is a module for enabling the caching of pages in order to avoid continuous query to the database?
Logged
pcwacht
AddOn Development
*
Offline Offline

Posts: 2814



WWW
« Reply #1 on: October 05, 2011, 03:28:38 PM »

Nope there is no such module


Did you search the forum on cache?

http://www.websitebaker2.org/forum/index.php/topic,14162.0.html

Have fun,
John
Logged

http://www.ictwacht.nl = Dutch ICT info
http://www.pcwacht.nl = My first
both still work in progress, since years.....
Paul - Westhouse IT

Offline Offline

Posts: 63


WWW
« Reply #2 on: October 05, 2011, 07:52:47 PM »

For something like that I'd recommend a more advanced CMS like Concrete5 (easy-to-use) or ExpressionEngine (highly extensible).
Logged

Westhouse IT - Professional WebsiteBaker developers for hire.
pcwacht
AddOn Development
*
Offline Offline

Posts: 2814



WWW
« Reply #3 on: October 05, 2011, 08:27:46 PM »

If it is mysql caching you need:

http://dev.mysql.com/doc/refman/5.1/en/query-cache.html
http://www.techiecorner.com/45/turn-on-mysql-query-cache-to-speed-up-mysql-query-performance/

But it might be enabled allready to boost overall performance.

John
Logged

http://www.ictwacht.nl = Dutch ICT info
http://www.pcwacht.nl = My first
both still work in progress, since years.....
NorHei
Forum administrator
*****
Offline Offline

Posts: 466


WWW
« Reply #4 on: October 06, 2011, 09:07:32 AM »

Jep, Mysql is caching queries by itself.

Caching is a quite complex topic . Many shared hosting companies already use proffessional caching solutions like Zend-Cache. (but they use it to place 2000 pepole on one server instead of 1000 whithout wink)

If got your own webserver the best solution ist to install a Server based caching solution:
http://en.wikipedia.org/wiki/List_of_PHP_accelerators.

Most CMS use  some kind of php based chaching mechanism to compensate for their incredible slow Templting engines (often 5 times slower if used whithout caching), and often those solutions are incompatible whith their server based counterparts.

So finding the right caching solution (if you really need one)for your needs depends on your hosting enviroment and on the kind of software you want to run. Especially on your hosting enviroment.

« Last Edit: October 06, 2011, 09:11:23 AM by NorHei » Logged

It is easier to change the specification to fit the program than vice versa.
smsoft

Offline Offline

Posts: 4


« Reply #5 on: October 06, 2011, 01:05:03 PM »

thank you to all.

I'm looking for a solution like http://www.websitebaker2.org/forum/index.php/topic,14663.0.html

I have already searched the forum and I only found this solution, just not very recent and does not seem very interesting, because otherwise makes use of a database query.
I have a very simple idea on how to create a caching system, how could I suggest to the websitebaker developers?

I do not want to directly edit my files, because if I should reapply the update changes
Logged
NorHei
Forum administrator
*****
Offline Offline

Posts: 466


WWW
« Reply #6 on: October 06, 2011, 06:41:52 PM »

Simply post, most Devs are reading here.

One last thing i want to mention is that the template engine planed to be used on 2.9+ already got a complete caching solution. For more Information take a look here : http://quickskin.worxware.com/  

But to be true. I cannot see to much use for such a modification, as if you on a low traffic page you don't need it , and if you are on a real high traffic site you need a professional solution whith a powerful Server anyway. So i don't get the point in writing a full scale cache just to reduce DB queries that are cached anyway ?  But i am no Dev....


http://www.theukwebdesigncompany.com/articles/php-caching.php
Maybe worth a look.
« Last Edit: October 06, 2011, 06:52:43 PM by NorHei » Logged

It is easier to change the specification to fit the program than vice versa.
Stefek
WebsiteBaker Org e.V.

Online Online

Posts: 4751



« Reply #7 on: October 06, 2011, 07:21:24 PM »

This is a nice article.
Like it!

One last thing i want to mention is that the template engine planed to be used on 2.9+ already got a complete caching solution. For more Information take a look here : http://quickskin.worxware.com/
This is a great Template Engine.
Used it several times now.
What I mostly like is its low-learning-curve for designers once the templates are prepared.
Just the good old WB way -> quick and easy.

Regards,
Stefek
Logged

"In a time of universal deceit, telling the truth becomes a revolutionary act."
- George Orwell, Nineteen eighty-four (1984)
pcwacht
AddOn Development
*
Offline Offline

Posts: 2814



WWW
« Reply #8 on: October 06, 2011, 08:50:43 PM »

Caching systems like the one here -> http://www.theukwebdesigncompany.com/articles/php-caching.php
could very easely be implemented in the template.

What a basic caching system does, in plain english is:

look if page allready was asked
-- if not - create it and store it in cache
serve it from cache

So basicly only the templates index.php needs to be changed
At the start there should be some code to check if there is a cached file and if it is not too old,
if it is not there make a chached page and show that
if it is show the cached page

I have allready implemented something like that ages ago, hence the pointer to the search in the forum, but I can't find it myself anymore, so it might be too old to be still here in the forum.

But I have a copy... Wink , I made it in 2005.

Since such a simple cache system can't tell if it needs to show dynamic info you just need a copy of the same template.
One WITH caching and ONE without, the siteadmin needs to set the caching template as default and those pages wich has dynamic content can be set to noncaching.

The code I used, at the very beginning of the templates index.php
Code:
<?php
  
// Caching settings Settings
  
$cachedir WB_PATH.'/cache/';                        // Directory to cache files in 
  
$cachetime 600;                                     // Seconds to cache files for
  
$cacheext 'cache';                                  // Extension to give cached files (usually cache, htm, txt)
  
$ignore_list = array(                                 // Ignore List
    
'/search',
  );
  
$page 'http://' $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];    // Requested page
  
$cachefile $cachedir md5($page) . '.' $cacheext;                  // Cache file to either load or create
  
$ignore_page false;
  for (
$i 0$i count($ignore_list); $i++) {
    
$ignore_page = (strpos($page$ignore_list[$i]) !== false) ? true $ignore_page;
  }
  
$cachefile_created = ((@file_exists($cachefile)) and ($ignore_page === false)) ? @filemtime($cachefile) : 0;
  @
clearstatcache();
  if (
time() - $cachetime $cachefile_created) {        // Show file from cache if still valid
    
@readfile($cachefile);
    exit();
  } else {
if (@file_exists($cachefile)) {                      // Delete old cache file
unlink ($cachefile);             
}   
  }
  
ob_start();                                            // If we're still here, we need to generate a cache file

and et the very end:
Code:
<?php
  $cachedir 
WB_PATH.'/cache/';                    // Directory to cache files in (keep outside web root)
  
$cacheext 'cache';                                   // Extension to give cached files (usually cache, htm, txt)
  
$page 'http://' $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; // Requested page
  
$cachefile $cachedir md5($page) . '.' $cacheext// Cache file to either load or create
  
$cachecontent=ob_get_contents();                       // save the contents of output buffer to the file
  
ob_end_flush(); 
  
$fp fopen($cachefile'w');                          // Now the script has run, generate a new cache file
  
fwrite($fp$cachecontent);                            // save the contents of output buffer to the file
  
fclose($fp); 
?>

I am not sure why I include the same settings at beginning and end, could be cause I was less experienced or that some variables got lost during the building.
However, make sure both sets of settings are the same!!

Have fun,
John
Logged

http://www.ictwacht.nl = Dutch ICT info
http://www.pcwacht.nl = My first
both still work in progress, since years.....
pcwacht
AddOn Development
*
Offline Offline

Posts: 2814



WWW
« Reply #9 on: October 06, 2011, 08:56:06 PM »

Quickskin is dated at the first day of 2009?
Is there still some development?


John
Logged

http://www.ictwacht.nl = Dutch ICT info
http://www.pcwacht.nl = My first
both still work in progress, since years.....
Stefek
WebsiteBaker Org e.V.

Online Online

Posts: 4751



« Reply #10 on: October 06, 2011, 10:03:06 PM »

Quickskin is dated at the first day of 2009?
Is there still some development?
I don't know if QuickSkin is further developped, but it is small and the class can be nicley enhanced/adjusted if needed.
It does its job very good.

I can just compare with the current TemplateEngine phpLib shipped with WB which is really old(school).

Compared with phpLib is QuickSkin much more "WB like".
And compared to SMARTY or similar overblunted engines... it's the best choice. (In my humble opinion)

Regards,
Stefek
Logged

"In a time of universal deceit, telling the truth becomes a revolutionary act."
- George Orwell, Nineteen eighty-four (1984)
Pages: [1]   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!