Recent Topics

Simple Cache Hack

Started by on Jun 21, 2005 – Contents updated: Jun 21, 2005

Jun 21, 2005 14:12    

This post has been intentionnally deleted by its author.

See:
[list]

  • [url=http://forums.b2evolution.net/viewtopic.php?t=4672]Simple Cache Hack[/url][/list:u]
  • for more information about the Simple Cache Hack.

    Jun 22, 2005 11:22

    [Intentionnally deleted]

    Jun 29, 2005 16:55

    ralphy wrote:

    The following code manages a simple cache system for b2evolution blogs.

    Other behaviors

    If the cache_on variable is set (including on the URL itself), the cache for that URL is used if it exists, whenever it's been created.

    If the cache_off variable is set (including on the URL itself), the cache is not used and the page is created from scratch.

    Remarks

    Since each URL produces its own cache file, the cache folder should be cleaned up on a regular basis, since there is an unlimited amount of possible URLs (since you can use search and add anything to the URL). That might be a security issue (flood attack)...

    Since each page is loaded by the server that is not you, your login state is probably wrong. Remember the following URLs (relative to your blog's directories; add these pages to your favorites before applying the hack): htsrv/login.php to login and admin/ to admin.

    Limitations

    The cache updates itself on its age. It does not take into account any changes in the page. In other words, posting a comment does not update the cache page. Be careful when using this (very) simple cache. I use it myself on a few pages of my blog only.

    Benchmarks
    Blog A, cache_off: 1,611 ms
    Blog A, cache_on: 347 ms

    This simple cache system should reduce your CPU usage a lot, especially on popular blogs/pages.

    Ralphy,

    I am SUPER GLAD to read your post and find out about your good work on this issue, which sounds it could be a major help for my blog, which I am tired of migrating every 2 or 3 weeks when the hosting service complains that the blog is grabbing an unacceptable portion of CPU Usage on a shared server.

    I have to confess I could not understand most of what you posted, I am only a user, not a programmer or coder, etc.

    Could you give me a couple of pointers on how to use the cache, for instance you say it does not update itself after a comment, what do I need to do to update the cache?

    And most important, what do you mean "be care careful when using it". You say you use it on certain pages only, do you think it would work for my entire blog which gets 80,000 page views and 15,000 unique visitors a day?

    Jun 29, 2005 17:41

    I have to leave for a week. I'm going to explain the "right" usage of this hack in a more "user friendly" way.

    The cache won't break anything in your blog. However, if you just implement it as is, people won't be able to see the comments they've just posted for 1 minute with the values given above.

    I've tested a slightly different/newer/better version of the cache system described here on my blog and it appears to work pretty fine with about 86% of my blogs pages successfully cached.

    There is no reason this hack would not work on your blog. Mine is "a bit" less popular (about 1,000 unique visitors and 2-5,000 pages a day), but if two people see the same page twice, this cache appears to be an interesting solution (since I don't know any other).

    I'm going to post more information once back next week.

    Have a look here: [url=http://turck-mmcache.sourceforge.net/index_old.html]Turck MMCache for PHP[/url]. It's a PHP compiler (and not a "real" cache). However, I haven't tested it yet.

    Jul 01, 2005 05:54

    Thank you for your answer... I tried implementing this, but my first hurdle is that in my installation there is no such file as "hacks.php" in the conf directory. I did create a _hacks.php file and placed it in the conf directoy, and also created a tmp directory (where exactly should I place this directory? I have in the the public folder). Then I did copy the code in my skin file (which I assume is main.php, right?). Also, where exactly should I place this code, you say "at the top" so I put it as the very first thing in my _main.php file for my skin.

    As you no doubt predicted after reading my installation attempt above, the cache is not working... can you please tell me in more detail where things go, what permissions are necessary (you say the tmp directory need to be accessed by the server, what are the permissions there?).

    Well, I'll wait until your return for instructions... the good thing is that after making the mods as you suggested above, my blog still works... even though nothing is being written to the tmp directory, so I assume the cache is not working.


    Form is loading...

    Build your own site! – This forum is powered by b2evolution CMS, a complete engine for your website.