• Resolved maxx203

    (@maxx203)


    Hi,

    i noticed about an issue with static cached pages and wp rocket. I suppose this issue does count for every static page cache prlugin. bbpress itself does have a new cached version as soon as a reply is written. However the reply is not shown on the post.

    Is there any function inside your plugin which can be used to have a proper cache after a reply is written?

Viewing 15 replies - 1 through 15 (of 20 total)
  • Plugin Author Robin W

    (@robin-w)

    sorry, only so much code I cab be familiar with, and wp rocket isn’t one of them πŸ™

    Thread Starter maxx203

    (@maxx203)

    Hello

    Thanks for your prompt reply. The problem is that your plugin does not regenerate the cache for the post. You could use WordPress default features for it.

    However. Is there any recommendation for static page caches and Plugin for it which would work with your plugin?

    Plugin Author Robin W

    (@robin-w)

    thanks for your further post.

    I am nit the original author of this plugin, I merely got added to try and get it working with Gutenberg.

    I am happy to improve it, but I have little tie to do so.

    If you have a link to an article in how to do what you want, or some example/model code, the I’d be happy to look at it.

    Thread Starter maxx203

    (@maxx203)

    Hi Robin,

    in my specific case i would like to have this to triggered once a reply was created.

    https://docs.wp-rocket.me/article/93-rocketcleanpost

    This will pruge the page cache and wp rocket create a new cached page then.

    However since now i wasnt able to have the post id there and it might be needed that your plugin will call the purge.

    Plugin Author Robin W

    (@robin-w)

    ok, totally untested, but this code might do the trick. I can’t test as I don’t have wp-rocket

    add_action( 'bbp_new_reply_post_extras', 'rew_purge_cache_reply' );
    add_action( 'bbp_edit_reply_post_extras', 'rew_purge_cache_reply' );
    add_action ('bbp_new_topic_post_extras' , 'rew_purge_cache_topic' ) ;
    add_action ('bbp_edit_topic_post_extras' , 'rew_purge_cache_topic' ) ;
    
    function rew_purge_cache_reply ($reply_id) {
    	$topic_id = bbp_get_reply_topic_id ($reply_id) ;
    	rew_purge_cache_topic ($topic_id) ;
    }
    
    function rew_purge_cache_topic ($topic_id) {
    	$purge_posts = get_posts(
    				array(
    					'post_type'		=> apply_filters( 'bbppt_eligible_post_types', array( 'post', 'page' ) ),
    					'meta_key'		=> 'bbpress_discussion_topic_id',
    					'meta_value'	=> $topic_id
    				)
    	);
    			
    	if ( $purge_posts ) {
    		foreach ($purge_posts as $purge_post) {
    			if (function_exists ('rocket_clean_post'))rocket_clean_post ($purge_post->ID) ;
    		}
    	}
    }

    Put this in your child theme’s function file –

    ie wp-content/themes/%your-theme-name%/functions.php

    where %your-theme-name% is the name of your theme

    or use
    https://en-gb.wordpress.org/plugins/code-snippets/

    if it works, then I’ll incorporate it into a new version.

    Thread Starter maxx203

    (@maxx203)

    Hello Robin,

    on my first tests your code is working as expected. Thank you very much.
    I will check it a bit more and provide you with another feedback once caches are created fully.

    Thread Starter maxx203

    (@maxx203)

    Hi Robin,

    your code is fully functional and you can include it into the plugin. Consider also to include into the plugin description that it is now WP rocket compatibel. If you want to test anything, feel free to provide me the changes and i will try it for you.

    Plugin Author Robin W

    (@robin-w)

    thanks, I’ll make the change in the next few days – I’ll post here to say i have done so, and you can remove the above code at that stage.

    Plugin Author Robin W

    (@robin-w)

    ok, this should be in version 1.9.5 being released shortly.

    Please take out the code I gave you above, and update.

    If you can confirm that this then works, that would be great !!

    Thread Starter maxx203

    (@maxx203)

    Hi Robin,

    i have revoked the code from functions.php, cleared cache and updated to plugin. I was not able to see that the fix inside your plugin is working. The cache was not recreated without the code inside functions.php.

    By reincluding your code inside the fuctions.php everything is working properly again.

    Plugin Author Robin W

    (@robin-w)

    Thanks, I’ll take another look, but yes just continue to use my code.

    Thread Starter maxx203

    (@maxx203)

    Btw. i also found that the thread is not created with read more link anymore. Are you aware about this issue?

    • This reply was modified 2 years, 9 months ago by maxx203.
    Plugin Author Robin W

    (@robin-w)

    I don’t use this plugin, as I said I only tried to get it working again.

    I don’t know what you mean by ‘thread’ – a wp post, bbpress topic or reply or something else?

    I’m quite happy to take a look, but I need a set of detailed steps to create the problem, good enough for a 5 year old to follow.

    Thread Starter maxx203

    (@maxx203)

    Hi Robin,

    i mean bbpress topic which is created by the plugin when a post is published. There is a link missing to the original post.

    • This reply was modified 2 years, 9 months ago by maxx203.
    Plugin Author Robin W

    (@robin-w)

    I’m quite happy to take a look, but I need a set of detailed steps to create the problem, good enough for a 5 year old to follow.

Viewing 15 replies - 1 through 15 (of 20 total)
  • The topic ‘WP Rocket Support / Static Caching Support’ is closed to new replies.