WordPress.org

Ready to get started?Download WordPress

Forums

WP Super Cache
Maybe a bug when using $protocol (7 posts)

  1. Haoxian
    Member
    Posted 1 year ago #

    Hi, donncha,

    When using https at admin panel but http at front, the related post page supercache file could not be refreshed properly. I ran some tests and found the problem.

    After replying or approving a comment, the related post page should be re-supercached. But it's not. And here is the related log with highlighted text:

    09:23:21 /wp-admin/admin-ajax.php Post 1932 changed. Update cache.
    09:23:21 /wp-admin/admin-ajax.php get_current_url_supercache_dir: warning! site_url (<strong>https://cnzhx.net</strong>) not found in permalink (<strong>http://cnzhx.net</strong>/blog/upgrade-to-wp30-multisite-subdirectory/).
    09:23:21 /wp-admin/admin-ajax.php get_current_url_supercache_dir: <strong>Removing SERVER_NAME (cnzhx.net) and https:// from permalink (http://cnzhx.net/blog/upgrade-to-wp30-multisite-subdirectory/). Is the url right?</strong>
    09:23:21 /wp-admin/admin-ajax.php <strong>supercache dir: /srv/www/cnzhx.net/public_html/wp-content/cache/supercache/cnzhx.nethttp://blog/upgrade-to-wp30-multisite-subdirectory/</strong>
    09:23:21 /wp-admin/admin-ajax.php wp_cache_post_id_gc post_id: 1932 http://cnzhx.net/blog/upgrade-to-wp30-multisite-subdirectory/ clearing cache in /srv/www/cnzhx.net/public_html/wp-content/cache/supercache/cnzhx.nethttp://blog/upgrade-to-wp30-multisite-subdirectory/.
    09:23:21 /wp-admin/admin-ajax.php wp_cache_post_id_gc clearing cache in /srv/www/cnzhx.net/public_html/wp-content/cache/supercache/cnzhx.nethttp://blog/upgrade-to-wp30-multisite-subdirectory//page/.
    09:23:21 /wp-admin/admin-ajax.php wp_cache_post_id_gc clearing cache in /srv/www/cnzhx.net/public_html/wp-content/cache/supercache/cnzhx.net//page/.
    09:23:21 /wp-admin/admin-ajax.php Post change: deleting cache files in /srv/www/cnzhx.net/public_html/wp-content/cache/supercache/cnzhx.net/
    09:23:21 /wp-admin/admin-ajax.php prune_super_cache: wp_cache_rebuild_or_delete( /srv/www/cnzhx.net/public_html/wp-content/cache/supercache/cnzhx.net/index.html )
    09:23:21 /wp-admin/admin-ajax.php rebuild_or_gc: rename to /srv/www/cnzhx.net/public_html/wp-content/cache/supercache/cnzhx.net/index.html.needs-rebuild
    09:23:21 /wp-admin/admin-ajax.php prune_super_cache: wp_cache_rebuild_or_delete( /srv/www/cnzhx.net/public_html/wp-content/cache/supercache/cnzhx.net/index.html.gz )
    09:23:21 /wp-admin/admin-ajax.php rebuild_or_gc: rename to /srv/www/cnzhx.net/public_html/wp-content/cache/supercache/cnzhx.net/index.html.gz.needs-rebuild
    09:23:21 /wp-admin/admin-ajax.php wp_cache_post_edit: Clearing cache for post 1932 on post edit.
    09:23:21 /wp-admin/admin-ajax.php wp_cache_post_change: Already processed post 1932.
    09:23:21 /wp-admin/admin-ajax.php wp_cache_post_change: Already processed post 1932.

    I looked into the source file wp-cache-phase1.php and changed line 524
    $uri = str_replace( $WPSC_HTTP_HOST, '', $permalink );
    to

    $uri = str_replace( 'https://', '', $uri );
    $uri = str_replace( 'http://', '', $uri );

    then tested it. Here is the new log:

    11:35:48 /wp-admin/admin-ajax.php Post 6658 changed. Update cache.
    11:35:48 /wp-admin/admin-ajax.php get_current_url_supercache_dir: warning! site_url (https://cnzhx.net) not found in permalink (http://cnzhx.net/blog/restrict-baidu-index-with-robots_txt/).
    11:35:48 /wp-admin/admin-ajax.php get_current_url_supercache_dir: Removing SERVER_NAME (cnzhx.net) and https:// from permalink (http://cnzhx.net/blog/restrict-baidu-index-with-robots_txt/). Is the url right?
    11:35:48 /wp-admin/admin-ajax.php supercache dir: /srv/www/cnzhx.net/public_html/wp-content/cache/supercache/cnzhx.net/blog/restrict-baidu-index-with-robots_txt/
    11:35:48 /wp-admin/admin-ajax.php wp_cache_post_id_gc post_id: 6658 http://cnzhx.net/blog/restrict-baidu-index-with-robots_txt/ clearing cache in /srv/www/cnzhx.net/public_html/wp-content/cache/supercache/cnzhx.net/blog/restrict-baidu-index-with-robots_txt/.
    11:35:48 /wp-admin/admin-ajax.php prune_super_cache: wp_cache_rebuild_or_delete( /srv/www/cnzhx.net/public_html/wp-content/cache/supercache/cnzhx.net/blog/restrict-baidu-index-with-robots_txt/index.html )

    Because the snippet is order to retrieve the supercache dir, I think it's ugly but not wrong to do it this way.

    BTW, you maybe notice that the sub-page url of home page is not right, such as prune_super_cache: deleted /srv/www/cnzhx.net/public_html/wp-content/cache/supercache/cnzhx.net//page/3/index.html. I'm using muiltisite mode and the proper url is cnzhx.net/blog/page/3/index.html.

    Please look into it and make an update for this. Thank you!

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

  2. Bill Dennen
    Member
    Posted 1 year ago #

    Thanks for this workaround, lonelicloud.

    In the latest version of WP Super Cache, the line to change is Line 536.

    I've made the change and now it seems to clear out ALL of the cache when a post/page is edited, not just the cache for the specific page/post.

  3. Haoxian
    Member
    Posted 1 year ago #

    Thanks for updated info.

    But this treatment is not perfect and would cause another problem while using https connection and http at the same time. The problem would be that the https version of cache would not be updated. It's a delemma for me.

  4. Bill Dennen
    Member
    Posted 1 year ago #

    I see your other post, here:

    http://wordpress.org/support/topic/wp-super-cache-prune-problem-with-ssl-on?replies=1

    I am having the same problems.

  5. Haoxian
    Member
    Posted 1 year ago #

    It's a good alternate to make WPSC clear ALL the cache by changing its settings, I think.

  6. jkhongusc
    Member
    Posted 11 months ago #

    We are running WP multisite subdomain. Our blogs utilize both http and https. In WP 3.5.2 and WP Super Cache 1.3.2, we have found problems (differences) between the http and https cache. The first problem I was tracking down was that our http cache was current but our https cache was old.

    lonelicloud -
    your modification about sounded like something we needed to do. I tried it out and unfortunately it did not help. I could not verify that section of code was incorrect so I backed out of the changes.

    In our case, when you update a post, all the index pages should be updated . What we were seeing was only the <SC cache dir>/dir/index.html being updated but not <SC cache dir>/dir/index-https.html. For our case we had two problems:
    1) I found that the cache urls where not build correctly - saw debug logs (notice missing slash) <SC cache dir>/dirindex.html I had to add this line to our code in function wp_cache_post_change() around lines #1130 and #1140

    foreach( $files_to_check as $cache_file ) {
        $dir .= (substr($dir, -1) == '/' ? '' : '/'); // adds slash
        prune_super_cache( $dir . $cache_file, true, true );
     }

    2) Fixing problem #1 marks all index pages for rebuild (.needs-rebuild) but we found out in certain situations, that SC will continue to use the old index pages! So we made this additional chage in function wpcache_do_rebuild() around line #115

    if( $mtime && (time() - $mtime) < 30 ) {
        if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Rebuild file renamed to cache file temporarily: $cache_file", 3 );
    //    @rename( $cache_file . '.needs-rebuild', $cache_file ); // comment out, next code section will remove/unlink
    }

    I am not sure if #1 and #2 are related to your problem (they sound similar). Those changes fixed our environment. FYI, I found other sections of SC code that did not take https into consideration. I would consider those code parts buggy, but I do not make changes unless it fixes a problem.

  7. Haoxian
    Member
    Posted 11 months ago #

    jkhongusc:

    Thanks for sharing this!

    You're right about this. Our concerns are cache-rebuilding related to https protocol but in different side.

    I look forward into this problem but can not find a perfect solution. So I 'm using WPSC now. That's alright for me.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic