WordPress.org

Ready to get started?Download WordPress

Forums

WP Cache Block
Great plugin, needs more admin settings (19 posts)

  1. Arash
    Member
    Posted 3 years ago #

    Finally a cache plugin that does not cache everything! I have tried 4 different cache plugins and they all effect my CPM ads! This is the only one that doesn't.

    Just a few points.

    1. the tmp file is not emptyed, even when flushing the cache!
    2. how long are things cached? Can we please set this in admin?
    3. is it possible to set cache time per area?
    4. When deactivating the plugin, can you please remove the /tmp folder and all its content?

    Thank you for creating this plugin!

    http://wordpress.org/extend/plugins/wp-cache-block/

  2. Arash
    Member
    Posted 3 years ago #

    Also noticed that the following code only works once.

    <?php if(wp_cacheblock_start('my-content')) : ?>
    //the content you want to cache
    <?php endif; wp_cacheblock_end(); ?>

    So if there are different blocks you want to cache, like header, footer and parts of sidebar. Then that does not work. You get the same data in all 3.

  3. prettyboymp
    Member
    Plugin Author

    Posted 3 years ago #

    Hi John,

    1. What object cache implementation are you using? WP Cache Block doesn't store any data in a /tmp file. It uses WordPress' built in caching to store the output of the section. If this isn't getting cleared, it is the caching plugin you are using.

    2. You can set the cache time out per section. The second parameter of the wp_cacheblock_start() function takes an array of settings. So if you need the cache to be for 30 seconds instead of the default 5 minutes use:

    `wp_cache_block_start('my-content', array('expires'=>30))

    3. See #2

    4. See #1

    5. The code is only working once because you are using the same blockname for each block. The first parameter of the wp_cacheblock_start() function should be unique per piece of content. So instead of using 'my-content', change it to something more descriptive like 'left-sidebar'.

  4. Arash
    Member
    Posted 3 years ago #

    Thank you I am going to try that.

  5. doctorcilantro
    Member
    Posted 3 years ago #

    I have applied this to some simple rotating javascript banner, and I would like to apply it to other php files. Do I use the same descriptor (my-content etc) if it is the exact same code, but just in a different location (php file)?

    thanks!

  6. prettyboymp
    Member
    Plugin Author

    Posted 3 years ago #

    Only use the same block-name if you want the same cached output for the other blocks where you call the same code.

  7. kduffey
    Member
    Posted 2 years ago #

    Do the cached blocks get automatically re-freshed upon a new post being published? What are the triggers that force a refresh on the cached blocks?

  8. prettyboymp
    Member
    Plugin Author

    Posted 2 years ago #

    No, since the block you may be caching might have nothing to do with posts, the cacheblocks timeout at 5 minute increments by default. If you need to clear the cache after a post is saved, you could add a hook to 'save_post' that will call back to WP_Cache_Block::GetInstance()->clear_cache();

  9. kduffey
    Member
    Posted 2 years ago #

    ok, so we could basically cache our main page also which basically shows an image and excerpt for the last 20 or so posts, and add a hook to clear the cache upon a 'save_post' ?

    Would that be what you would recommend?

  10. kduffey
    Member
    Posted 2 years ago #

    prettyboymp:

    I successfully added a hook to clear the cache in the event of a new post. As such, wouldn't it make sense to lengthen the expiration period of the cache blocks?

    Is there any reason not to extend it to 20 minutes or so? Would it help performance?

    I'm not caching comments so its all static content except when a new post is created which is taken care of by the hook.

  11. prettyboymp
    Member
    Plugin Author

    Posted 2 years ago #

    Truthfully, if you're clearing the cache when you save a new post and there is no other source of new content on the homepage that would need to otherwise be refreshed, you could set the expire argument to 0. This would keep it from ever clearing from cache except when you save a post.

  12. cozmic_
    Member
    Posted 2 years ago #

    i wonder that where the cached bloks are stored? To the disk or memory(ram)?

  13. kduffey
    Member
    Posted 2 years ago #

    prettyboymp:

    Does the plugin use the wordpress options table to store data? Does it use records such as _transient_XXXXXXXXX?

    My wordpress options table has gotten extremely bloated and I'm trying to clean it out and am trying to find where the records came from.

    Let me know if you have any feedback. Thanks so much.

  14. prettyboymp
    Member
    Plugin Author

    Posted 2 years ago #

    kduffy:

    The plugin uses WordPress' transient api, which is the built in caching wrapper for WordPress. If you're not running a separate object cache, then yes, these items get stored in the options table with option names of _transient_xxxxxx.

  15. kduffey
    Member
    Posted 2 years ago #

    Ok thanks.

    I think you should know that as a result, I've got 250,000 records in my options table now all with that transient prefix and it has killed my CPU usage b/c the options table gets read in by wordpress w/ each page view.

    Is this an error w/ the plugin or did I set it up wrong?

  16. kduffey
    Member
    Posted 2 years ago #

    Is there an easy way to delete these records with the plugin or do i need to do it manually in the database?

  17. kduffey
    Member
    Posted 2 years ago #

    To follow up on the above, my database grew from 36mb to 1.2gb w/ the transient records.

    Did you have any feedback on that? I'm just trying to help and also find out if i configured it incorrectly in some way? I like the functionality of the plugin but obviously this killed my server so I had to deactivate into further clarification.

  18. prettyboymp
    Member
    Plugin Author

    Posted 2 years ago #

    You'll have to delete the transient rows manually. I incorrectly assumed that WordPress cleaned up it's own expired transients, but actually doesn't. The plugin works fine as long as you're using a real object cache, but if not, you will run into the issue you had. I'll try to get a fix released soon to correct this.

  19. smart1k
    Member
    Posted 2 years ago #

    To kduffey You can also use object cacheing plugins for ex. WP File Cache. "WP File Cache shifts the load from your database to your disk/file system", you can also try SJ Object Cache. The same author, same functionality but with some "sweet" extras. You can store cached objects in shared memory(with help of XCache, APC, Memcache, EAccelerator)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic