WordPress.org

Ready to get started?Download WordPress

Forums

W3 Total Cache
BUG: Preloading loads the same page several times at the same time (11 posts)

  1. niska
    Member
    Posted 3 years ago #

    I have a problem with several of my plugins. It took a while to locate the problem - but now I've found it.

    To test it, use the following plugin:

    <?php
    /*
    Plugin Name: Test
    Plugin URI: http://www.test.com/test/
    Description:
    Version: 1.0
    Author: Niska
    Author URI: http://www.test.com/test/
    */
    
    function niskatest ($content) {
    	$postid   = get_the_ID();
    	update_post_meta($postid, 'niskatest', time());
    
    	if (preg_match('/W3 Total Cache/', $_SERVER['HTTP_USER_AGENT'])) {
    		$message .= print_r($_SERVER, true);
    		wp_mail(get_option('admin_email'), 'Post ' . $postid . ' fetched by W3TC at ' . time(), $message, "From: Niskatest.com <test@niskatest.com>\r\n");
    	}
    
    	return $content;
    }
    add_filter('the_content', 'niskatest');
    ?>

    Then activate the plugin and activate preloading in W3TC. After a while you will start getting emails. And you will notice that several of the emails are for the same posts.

    If you check one of these posts, you will find that it has several custom fields that look like this:

    niskatest 1296764608
    niskatest 1296764608
    niskatest 1296764609

    This is not correct. There should only be one custom field named 'niskatest'.

    You can try this out by using the plugin above.

  2. niska
    Member
    Posted 3 years ago #

    FYI: I have set up cron to run every 10 minutes (*/10 * * * *) running this command

    wget -O /dev/null http://www.niskatest.com/wp_cron.php >/dev/null 2>&1

    Note: the niskatest.com domain is not the real domain.

  3. niska
    Member
    Posted 3 years ago #

    This seems to be solved in the current development version.

  4. niska
    Member
    Posted 3 years ago #

    Nope. Not solved. I'm seeing duplicate custom fields again..

  5. niska
    Member
    Posted 3 years ago #

    Any ideas?

  6. Frederick Townes
    Member
    Plugin Author

    Posted 3 years ago #

    It's quite common for multiple instances of WP Cron to be instantiated so you might want to disable WP Cron on your site if you're calling it via OS.

  7. kg
    Member
    Posted 3 years ago #

    Nice post - I've been wondering why i was getting dupe meta values in my posts lately. I'll switch to using OS cron, thanks ;-)

  8. kg
    Member
    Posted 3 years ago #

    Switchover done - issue still remains.

  9. kg
    Member
    Posted 3 years ago #

    disabling db cache fixed the issue for me so far.

  10. niska
    Member
    Posted 3 years ago #

    Frederick: I've checked with my host provider. And they say that cronjobs should only run once. They also checked that there was not several instances of cron running at the same time.

    I've set up cron this way

    */5 * * * * * wget -O /dev/null http://www.mysite.com/cron.php

    Should I do something else? I'm not sure what you mean by "disable WP Cron". Could you be more specific?

    kg: I'll try to disable db cache.

  11. Frederick Townes
    Member
    Plugin Author

    Posted 3 years ago #

    Was there any news here?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic