Categories > TinyButStrong general >

Caching very slow...what other caching you can recommend

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Milop
Date: 2012-09-25
Time: 14:43

Caching very slow...what other caching you can recommend

Hello,

I decided to go tinybutstrong for making very light blogging platform that doesn't require mysql.
I wanted to use SQLite.

Anyway, I found that small page loads much slower then page of similar size on worpress.
And I guess that issue is in caching plugin.
So, can you recommend some other simple php file caching system that will work with tinybutstrong ?


Here is my code, maybe something is wrong:

index.php file:
<?php

$db = new PDO('sqlite:articlesDb_PDO.sqlite');

include_once('include/tbs_class.php');

$TBS = new clsTinyButStrong;

include_once('include/tbs_plugin_cache.php');

$TBS->PlugIn(TBS_CACHE, 'index', 3600,'./cache');


$TBS->LoadTemplate('theme/index.php');

$index_post= $TBS->MergeBlock('index_post',$db,'SELECT * FROM Articles order by id asc limit 0,10');

$TBS->Show();


?>

And here is template file:

[onload;file=header.php]
        <div id="container">
            <div id="content" role="main">
       
<h2 class="entry-title"><a href="single.php?id=[index_post.id]">[index_post.keyword;block=h2]</a></h2>
<div class="main entry-content group">[index_post.article;block=div]</div>   
   
            </div><!-- #content -->
        </div><!-- #container -->
[onload;file=sidebar.php]
[onload;file=footer.php]

By: Milop
Date: 2012-09-25
Time: 17:59

Re: Caching very slow...what other caching you can recommend

I changed my code after reading forum to this:

<?php
    
include_once('include/tbs_class.php');

$TBS = new clsTinyButStrong;

include_once('include/tbs_plugin_cache.php');

if( !$TBS->PlugIn(TBS_CACHE,'index', 3600,'./cache') ) {

    $TBS->LoadTemplate('theme/index.php');

    $db = new PDO('sqlite:articlesDb_PDO.sqlite');
    $index_post= $TBS->MergeBlock('index_post',$db,'SELECT * FROM Articles order by id asc limit 0,10');

    $TBS->Show();

}

?>

With this code page is loading a little bit faster then before, but still much slower then wordpress page.
Any idea ?
By: Skrol29
Date: 2012-09-26
Time: 01:25

Re: Caching very slow...what other caching you can recommend

Hi Milop,

I've tested your code and template with a simple SQLite database and it was fast.
I've seen only one little problem in your template :
[index_post.keyword;block=h2] should be replaced with [index_post.keyword;block=h2+div]
and [index_post.article;block=div] should be replaced with [index_post.article].

It could be good to put some timer measures in your code in order to check where is the slow process.
By: Milop
Date: 2012-09-26
Time: 09:49

Re: Caching very slow...what other caching you can recommend

I have used whichloadsfaster.com and pingdom to test load time of this TBS page (code from post above):
http://www.7ccv.com/02/
and this wordpress page:
http://www.7ccv.com/

TBS page is two times smaller in size (KBs) and has much much less requests with external objects but still loads two times (or more) slower then wordpress.
My SQLite file is 27MB big, but it doesn't affect as this is all cached in single static file and DB is not loaded (I hope) on each run.

Do you have any idea where in caching could be problem ?
From code abode it looks for me that it should load static cached file and that it should load very very fast.
By: Skrol29
Date: 2012-09-27
Time: 01:10

Re: Caching very slow...what other caching you can recommend

>From code abode it looks for me that it should load static cached file and that it should load very very fast.

I agree, and my test shown that it is the case.

> Do you have any idea where in caching could be problem ?

Can you send to me a set of files in order to reproduce the problem ?
By: Milop
Date: 2012-09-27
Time: 07:50

Re: Caching very slow...what other caching you can recommend

>  Can you send to me a set of files in order to reproduce the problem ?
I sent you email.

Many many thanks!
By: Skrol29
Date: 2012-10-01
Time: 22:19

Re: Caching very slow...what other caching you can recommend

Hi Milop,

Thanks fr your files.
I've tested them and all was running quite very fast.

I've inserted some timing code in your main script in order to have time measures.
Here is the code:
<?php
    
include_once('include/tbs_class.php');

$TBS = new clsTinyButStrong;

//caching
include_once('include/tbs_plugin_cache.php');

$TBS->Render = TBS_NOTHING;
$t1 = microtime();

if( !$TBS->PlugIn(TBS_CACHE,'index', 360000,'./cache') ) {

    echo "<p>creation</p>";

    $TBS->LoadTemplate('theme/index.php');

    $head_title = 'Here is title';
    $head_description = 'Here is descrption';
    $db = new PDO('sqlite:articlesDb_PDO.sqlite');
    $index_post= $TBS->MergeBlock('index_post',$db,'SELECT * FROM Articles order by id asc limit 0,10');

    $TBS->Show();

} else {

    echo "<p>cached</p>";

}

$t2 = microtime();
echo "<p>duration:".($t2-$t1)."</p>";
echo $TBS->Source;

And here is the head of the result:
cached
duration:0.00069599999999997
The ending was the articles.

When the cache is over, the heade of the result is:
creation
duration:0.06985

So the problem bay be in your PHP configuration or you computer.
Regards,