Forums

WP Super Cache
[resolved] One of the root causes of the timestamps difference (7 posts)

  1. Tats Shibata
    Member
    Posted 6 months ago #

    Some people report a problem about "The pages do not match! Timestamps differ or were not found!" with Cache Tester. I also had it but found one of the root causes, which seems to be a bug.

    The cache for the front page are always re-generated when certain WordPress settings are used. Therefore, the timestamps always differ.

    * VERSION

    WordPress 3.2.1
    WP Super Cache 0.9.9.9

    * SETTINGS

    Settings > General > WordPress address (URL): http://rewse.jp/blog
    Settings > Permalinks > Custom Structure: /p/%post_id%

    WP Super Cache > Advanced > Caching: Use PHP to serve cache files.

    * ANALYSIS

    wp-cache.php:

    if ( substr( get_option( 'permalink_structure' ), -1 ) == '/' ) {
      wp_cache_replace_line('^ *\$wp_cache_slash_check', "\$wp_cache_slash_check = 1;", $wp_cache_config_file);
    } else {
      wp_cache_replace_line('^ *\$wp_cache_slash_check', "\$wp_cache_slash_check = 0;", $wp_cache_config_file);
    }

    $wp_cache_slash_check is set to 0 when get_option('permalink_structure') is "/p/%post_id%".

    wp-cache-phase1.php:

    if (
      (
        $wp_cache_request_uri == '/' ||
        ( $wp_cache_slash_check && substr( $wp_cache_request_uri, -1 ) == '/' ) ||
        ( $wp_cache_slash_check == 0 && substr( $wp_cache_request_uri, -1 ) != '/' )
      ) &&
      ( wp_cache_get_cookies_values() == '' && empty( $_GET ) && $serving_supercache ) )

    $wp_cache_request_uri is "/blog/" when http://rewse.jp/blog/ is accessed. By the above, $wp_cache_slash_check is 0. These 2 values mean this if statement is always false -- always goes to "No wp-cache file exists. Must generate a new one." -- when http://rewse.jp/blog/ is accessed.

    * WORKAROUND

    I confirmed to fix it by the below dirty huck.

    if (
      (
        $wp_cache_request_uri == '/blog/' ||

    * DEBUG LOGS

    Before workaround:

    01:04:11 /blog/ supercache dir: /var/lib/wordpress/rsrc/cache/supercache/rewse.jp/blog/
    01:04:11 /blog/ No wp-cache file exists. Must generate a new one.
    01:04:12 /blog/ In WP Cache Phase 2
    01:04:12 /blog/ Setting up WordPress actions
    01:04:12 /blog/ Created output buffer
    01:04:13 /blog/ Output buffer callback
    01:04:13 /blog/ Anonymous user detected. Only creating Supercache file.
    01:04:13 /blog/ Gzipping buffer.
    01:04:13 /blog/ Writing non-gzipped buffer to supercache file.
    01:04:13 /blog/ Writing gzipped buffer to supercache file.
    01:04:13 /blog/ Renamed temp supercache file to /var/lib/wordpress/rsrc/cache/supercache/rewse.jp/blog/index.html
    01:04:13 /blog/ Renamed temp supercache gz file to /var/lib/wordpress/rsrc/cache/supercache/rewse.jp/blog/index.html.gz
    01:04:13 /blog/ Writing gzip content headers. Sending buffer to browser
    01:04:13 /blog/ wp_cache_shutdown_callback: collecting meta data.
    01:04:39 /blog/ supercache dir: /var/lib/wordpress/rsrc/cache/supercache/rewse.jp/blog/
    01:04:39 /blog/ No wp-cache file exists. Must generate a new one.
    01:04:39 /blog/ In WP Cache Phase 2
    01:04:39 /blog/ Setting up WordPress actions
    01:04:39 /blog/ Created output buffer
    01:04:40 /blog/ Output buffer callback
    01:04:40 /blog/ Anonymous user detected. Only creating Supercache file.
    01:04:40 /blog/ Gzipping buffer.
    01:04:40 /blog/ Writing non-gzipped buffer to supercache file.
    01:04:40 /blog/ Writing gzipped buffer to supercache file.
    01:04:40 /blog/ Renamed temp supercache file to /var/lib/wordpress/rsrc/cache/supercache/rewse.jp/blog/index.html
    01:04:40 /blog/ Renamed temp supercache gz file to /var/lib/wordpress/rsrc/cache/supercache/rewse.jp/blog/index.html.gz
    01:04:40 /blog/ Writing gzip content headers. Sending buffer to browser
    01:04:40 /blog/ wp_cache_shutdown_callback: collecting meta data.

    After workaround:

    01:08:34 /blog/ supercache dir: /var/lib/wordpress/rsrc/cache/supercache/rewse.jp/blog/
    01:08:34 /blog/ Served page from supercache file using PHP.
    01:08:48 /blog/ supercache dir: /var/lib/wordpress/rsrc/cache/supercache/rewse.jp/blog/
    01:08:48 /blog/ Served page from supercache file using PHP.

    Thanks,
    Tats

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

  2. Donncha O Caoimh
    Member
    Posted 6 months ago #

    So, the problem is that your site isn't at /, but rather at /blog/. I think I need to cache that somewhere as WordPress hasn't loaded yet when this code runs. Thanks for reporting that!

  3. Donncha O Caoimh
    Member
    Posted 6 months ago #

    Try the development version. It's on the "Other versions" page and using it I couldn't replicate this problem on a test site.

    Hmm, even tried this using 0.9.9.9 and it worked fine. I'm not sure why it's not working for you.

  4. Tats Shibata
    Member
    Posted 6 months ago #

    The development version doesn't fix that. Some other settings might be different between you and me.

    I put the below 2 lines just in front of the if statment (line 167 on wp-cache-phase1.php of the dev version).

    wp_cache_debug("wp_cache_slash_check: $wp_cache_slash_check", 5);
    wp_cache_debug("wp_cache_request_uri: $wp_cache_request_uri", 5);

    The below was my result. May I have your these 2 values?

    15:41:21 /blog/ wp_cache_slash_check: 0
    15:41:21 /blog/ wp_cache_request_uri: /blog/
  5. Donncha O Caoimh
    Member
    Posted 6 months ago #

    Thanks for that. After checking those I realised I hadn't set my permalinks correctly. I think this should be easy enough to fix.

  6. Donncha O Caoimh
    Member
    Posted 6 months ago #

    I've just checked a change into the plugin that should fix this. It'll be in the development version in a few minutes. Make sure you visit the settings page when you upgrade as that caches your home url.

  7. Tats Shibata
    Member
    Posted 6 months ago #

    I've just confirmed to fix that by the latest development version. Thanks a lot.

Reply

You must log in to post.

About this Plugin

About this Topic