WordPress.org

Ready to get started?Download WordPress

Forums

WP Super Cache
WP Super Cache prune problem with SSL on (3 posts)

  1. Haoxian
    Member
    Posted 1 year ago #

    Recently, I re-activated the WP Super Cache plugin to make my website( http://cnzhx.net ) responsing faster. But I noticed that the post cache was not updated aftering editing. Further dubugging shows the reason is that WP Super Cache does not deal with https related site properly.

    I find 2 related posts in this forum but the problem is still not resolved:

    1. Cache of edited post not updated - 4 years ago
    2. Update cache after edit? - 1 year ago

    Hope Donncha could fix the problem in next version. Thank you!

    Following is my debugging infomation and temporary solutions.

    1. Circumstances

    On my site, SSL (HTTPS) connection has been forced to use on wp-admin and wp-login pages.

    After this, users could visit the site with or without https connection, but it's always using https connection to visit the wp-admin area including post-edit.php page. And I think the WP Super Cache plugin using https connection to check post update status, too.

    2. Debug

    Check the debug option on ( WP Super Cache Settings --> Debug )and edit a post then update it. I get the following debug infomation:

    01:04:49 /wp-admin/post.php wp_cache_post_edit: Clearing cache for post 7138 on post edit.
    01:04:49 /wp-admin/post.php get_current_url_supercache_dir: warning! site_url (https://cnzhx.net) not found in permalink (http://cnzhx.net/blog/common-iptables-cli/).
    01:04:49 /wp-admin/post.php get_current_url_supercache_dir: Removing SERVER_NAME (cnzhx.net) and https:// from permalink (http://cnzhx.net/blog/common-iptables-cli/). Is the url right?
    01:04:49 /wp-admin/post.php supercache dir: /{HIDDEN_PATH}/cnzhx.net/public_html/{HIDDEN_URL}/wp-content/cache/supercache/cnzhx.nethttp://blog/common-iptables-cli/
    01:04:49 /wp-admin/post.php wp_cache_post_id_gc post_id: 7138 http://cnzhx.net/blog/common-iptables-cli/ clearing cache in /{HIDDEN_PATH}/cnzhx.net/public_html/{HIDDEN_URL}/wp-content/cache/supercache/cnzhx.nethttp://blog/common-iptables-cli/.
    01:04:49 /wp-admin/post.php wp_cache_post_id_gc clearing cache in /{HIDDEN_PATH}/cnzhx.net/public_html/{HIDDEN_URL}/wp-content/cache/supercache/cnzhx.nethttp://blog/common-iptables-cli//page/.
    01:04:49 /wp-admin/post.php wp_cache_post_id_gc clearing cache in /{HIDDEN_PATH}/cnzhx.net/public_html/{HIDDEN_URL}/wp-content/cache/supercache/cnzhx.net//page/.
    01:04:49 /wp-admin/post.php Post change: deleting cache files in /{HIDDEN_PATH}/cnzhx.net/public_html/{HIDDEN_URL}/wp-content/cache/supercache/cnzhx.net/
    .........( Homepage rebuilt correctly. ).........
    01:04:49 /wp-admin/post.php wp_cache_post_edit: Already processed post 7138.
    01:04:49 /wp-admin/post.php wp_cache_post_change: Already processed post 7138.

    The plugin detects and starts a cache clearing and rebuilding. It assumes that the post url is starting with https (ssl connection), but when it "browsing" the post, the actual url is starting with http.(line 2 and 3) So, the answer is "not right" when it asking "Is the url right?" in line 3. After that, it gets a wrong cache dir (line 4)

    /{HIDDEN_PATH}/cnzhx.net/public_html/{HIDDEN_URL}/wp-content/cache/supercache/cnzhx.nethttp://blog/common-iptables-cli/

    and old cache of the post is not cleared correctly (line 5).

    Addtionally, there are 2 DIRs are not actual exiting and being used in this process (line 6 and 7):

    /{HIDDEN_PATH}/cnzhx.net/public_html/{HIDDEN_URL}/wp-content/cache/supercache/cnzhx.nethttp://blog/common-iptables-cli<strong>//page/</strong>
    /{HIDDEN_PATH}/cnzhx.net/public_html/{HIDDEN_URL}/wp-content/cache/supercache/<strong>cnzhx.net//page/</strong>

    Highlighted with red font. I don't understantd the //page/ part. Eighter way, it's having nothing to do with the cache-not-rebuild-correctly problem.

    3. Temporary Solutions

    Here proposed 2 solutions. The first one is easy and not code related, while the second one needs to tamper codes of the WP Super Cache.

    A. Easy one

    Just don't use ssl (https) connection on the wp-admin pages and the problem goes away.

    B. Hard one

    This problem is caused by function get_current_url_supercache_dir which is located in wp-cache-phase1.php, line 494. Related code snippet is:

    if ( isset( $_SERVER[ 'HTTPS' ] ) )
        $protocol = ( 'on' == strtolower( $_SERVER[ 'HTTPS' ] ) ) ? 'https://' : 'http://';
    else
        $protocol = 'http://';
    if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "get_current_url_supercache_dir: Removing SERVER_NAME ({$WPSC_HTTP_HOST}) and $protocol from permalink ($permalink). Is the url right?", 1 );
    $uri = str_replace( $WPSC_HTTP_HOST, '', $permalink );
    $uri = str_replace( $protocol, '', $uri );

    So, I change the code snippet as following:

    if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "get_current_url_supercache_dir: Removing SERVER_NAME ({$WPSC_HTTP_HOST}) and $protocol from permalink ($permalink). Is the url right?", 1 );
    $uri = str_replace( $WPSC_HTTP_HOST, '', $permalink );
    $uri = str_replace( 'https://', '', $uri );
    $uri = str_replace( 'http://', '', $uri );

    It works! Now, the debug infomation looks like this:

    03:51:00 /wp-admin/post.php wp_cache_post_edit: Clearing cache for post 7138 on post edit.
    03:51:00 /wp-admin/post.php get_current_url_supercache_dir: warning! site_url (https://cnzhx.net) not found in permalink (http://cnzhx.net/blog/common-iptables-cli/).
    03:51:00 /wp-admin/post.php get_current_url_supercache_dir: Removing SERVER_NAME (cnzhx.net) and  from permalink (http://cnzhx.net/blog/common-iptables-cli/). Is the url right?
    03:51:00 /wp-admin/post.php supercache dir: /{HIDDEN_PATH}/cnzhx.net/public_html/{HIDDEN_URL}/wp-content/cache/supercache/cnzhx.net/blog/common-iptables-cli/
    03:51:00 /wp-admin/post.php wp_cache_post_id_gc post_id: 7138 http://cnzhx.net/blog/common-iptables-cli/ clearing cache in /{HIDDEN_PATH}/cnzhx.net/public_html/{HIDDEN_URL}/wp-content/cache/supercache/cnzhx.net/blog/common-iptables-cli/.
    03:51:00 /wp-admin/post.php prune_super_cache: wp_cache_rebuild_or_delete( /{HIDDEN_PATH}/cnzhx.net/public_html/{HIDDEN_URL}/wp-content/cache/supercache/cnzhx.net/blog/common-iptables-cli/index-https.html )
    03:51:00 /wp-admin/post.php rebuild_or_gc: rename to /{HIDDEN_PATH}/cnzhx.net/public_html/{HIDDEN_URL}/wp-content/cache/supercache/cnzhx.net/blog/common-iptables-cli/index-https.html.needs-rebuild
    03:51:00 /wp-admin/post.php prune_super_cache: wp_cache_rebuild_or_delete( /{HIDDEN_PATH}/cnzhx.net/public_html/{HIDDEN_URL}/wp-content/cache/supercache/cnzhx.net/blog/common-iptables-cli/index.html )
    03:51:00 /wp-admin/post.php rebuild_or_gc: rename to /{HIDDEN_PATH}/cnzhx.net/public_html/{HIDDEN_URL}/wp-content/cache/supercache/cnzhx.net/blog/common-iptables-cli/index.html.needs-rebuild
    03:51:00 /wp-admin/post.php prune_super_cache: wp_cache_rebuild_or_delete( /{HIDDEN_PATH}/cnzhx.net/public_html/{HIDDEN_URL}/wp-content/cache/supercache/cnzhx.net/blog/common-iptables-cli/index-https.html.gz )
    03:51:00 /wp-admin/post.php rebuild_or_gc: rename to /{HIDDEN_PATH}/cnzhx.net/public_html/{HIDDEN_URL}/wp-content/cache/supercache/cnzhx.net/blog/common-iptables-cli/index-https.html.gz.needs-rebuild
    03:51:00 /wp-admin/post.php prune_super_cache: wp_cache_rebuild_or_delete( /{HIDDEN_PATH}/cnzhx.net/public_html/{HIDDEN_URL}/wp-content/cache/supercache/cnzhx.net/blog/common-iptables-cli/index.html.gz )
    03:51:00 /wp-admin/post.php rebuild_or_gc: rename to /{HIDDEN_PATH}/cnzhx.net/public_html/{HIDDEN_URL}/wp-content/cache/supercache/cnzhx.net/blog/common-iptables-cli/index.html.gz.needs-rebuild
    #
    # After this line, the additonal / still exists before /page
    #
    03:51:00 /wp-admin/post.php wp_cache_post_id_gc clearing cache in /{HIDDEN_PATH}/cnzhx.net/public_html/{HIDDEN_URL}/wp-content/cache/supercache/cnzhx.net/blog/common-iptables-cli//page/.
    03:51:00 /wp-admin/post.php wp_cache_post_id_gc clearing cache in /{HIDDEN_PATH}/cnzhx.net/public_html/{HIDDEN_URL}/wp-content/cache/supercache/cnzhx.net//page/.
    03:51:00 /wp-admin/post.php prune_super_cache: deleted /{HIDDEN_PATH}/cnzhx.net/public_html/{HIDDEN_URL}/wp-content/cache/supercache/cnzhx.net//page/3/index.html
    03:51:00 /wp-admin/post.php prune_super_cache: deleted /{HIDDEN_PATH}/cnzhx.net/public_html/{HIDDEN_URL}/wp-content/cache/supercache/cnzhx.net//page/3/index.html.gz
    03:51:00 /wp-admin/post.php gc: deleted /{HIDDEN_PATH}/cnzhx.net/public_html/{HIDDEN_URL}/wp-content/cache/supercache/cnzhx.net//page/3, forced delete
    03:51:00 /wp-admin/post.php prune_super_cache: deleted /{HIDDEN_PATH}/cnzhx.net/public_html/{HIDDEN_URL}/wp-content/cache/supercache/cnzhx.net//page/2/index.html
    03:51:00 /wp-admin/post.php prune_super_cache: deleted /{HIDDEN_PATH}/cnzhx.net/public_html/{HIDDEN_URL}/wp-content/cache/supercache/cnzhx.net//page/2/index.html.gz
    03:51:00 /wp-admin/post.php gc: deleted /{HIDDEN_PATH}/cnzhx.net/public_html/{HIDDEN_URL}/wp-content/cache/supercache/cnzhx.net//page/2, forced delete
    03:51:00 /wp-admin/post.php Post change: deleting cache files in /{HIDDEN_PATH}/cnzhx.net/public_html/{HIDDEN_URL}/wp-content/cache/supercache/cnzhx.net/
    .........( Homepage rebuilt correctly. ).........
    03:51:00 /wp-admin/post.php wp_cache_post_edit: Already processed post 7138.
    03:51:00 /wp-admin/post.php wp_cache_post_change: Already processed post 7138.

    But I don't know if there are downsides with this tampering.

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

  2. straitline
    Member
    Posted 8 months ago #

    Haoxian,

    Are you still running this setup in WP Super Cache? Have you come across any problems with it.

    (Thanks for the extensive write up)

  3. Haoxian
    Member
    Posted 8 months ago #

    Hi, straitline,
    The same problem is still exist, even with WPSC 1.4. But I'm just tired of editting the code, so I havn't tested it yet. Now, I often re-builds the pre-cache manually in a week.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic