• Resolved Pratham

    (@pratham2003)


    We had a weird issue today where a WooCommerce product got published but it’s like was as if it was still a scheduled/draft post e.g. https://example.com/?product_type=product&p=123

    The only way I can see this happen is if some parts of the code think the product is published (which is why it appears in the frontend) but the generated permalink was still https://example.com/?product_type=product&p=123

    My first doubt was due to the object cache.
    The issue resolved itself within a minute before I could confirm if clearing the object cache fixed it.

    Additional info: my WP CRON runs every minute externally (Linux’s crontab). WP’s pseudo cron is disabled.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @pratham2003

    Thank you for your inquiry and I am happy to help!
    I’ve tried to replicate this, however, there are no issues if this kind after the tests are performed with Object Caching enabled.
    If the issue was resolved by itself that means that it’s not related to clearing OC. most likely a minor glitch when the product was published.
    Thanks!

    Thread Starter Pratham

    (@pratham2003)

    Hi Marko,

    Can you please confirm if you tried this with Redis-based object cache or file-based object cache? I wanted to rule out any differences there.

    The use case at our end is that these are flash sales with 100+ people waiting to buy the product. Even that 1-2 minutes of page-specific downtime where the URL appears broken and the product is not eligible to be in the cart is a major issue (suspecting due to difference in post_status stored in object cache & DB?).

    On my side, the following code seems to be resolving this issue.
    It clears the W3TC object cache when a product transitions from the future to publish status.

    function purge_object_cache_on_future_to_publish( $new, $old, $post ) {
        if ( $post->post_type == 'product' && $new == 'publish' && $old == 'future' ) {
    		if(function_exists('w3tc_objectcache_flush')) {
    			w3tc_objectcache_flush();
    		}
    	}
    }
    add_action( 'transition_post_status', 'purge_object_cache_on_future_to_publish', 10, 3 );
    
    • This reply was modified 3 years, 10 months ago by Pratham.
    • This reply was modified 3 years, 10 months ago by Pratham.
    • This reply was modified 3 years, 10 months ago by Pratham.
    Thread Starter Pratham

    (@pratham2003)

    @vmarko Please let us know if you were able to test and confirm this.
    This has been working perfectly at our side so far.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Does W3TC clear object cache automatically when a scheduled post gets published?’ is closed to new replies.