WordPress.org

Ready to get started?Download WordPress

Forums

WP Super Cache
WP Super Cache not refreshing post after comments made (16 posts)

  1. financialgod
    Member
    Posted 2 years ago #

    On the site financialgod.com, I have a problem with WP Super Cache and cached pages: They do not get refreshed when comments are made. This seems to happen regardless of whether preloading is on or not. Only a known user sees the comments, as they are not served cached data.

    When I look in the "cache" directory and observe the supercached file, I can see that it has not been updated. I am not getting a 404 error on wp_cron. In the debug logs I can see it tries to clear the supercache, but something about the path seems wrong -- the "http:/www.financialgod.com" should not be part of the file path:

    13:43:12 /wordpress/wp-admin/admin-ajax.php wp_cache_post_id_gc post_id: 451 http://www.financialgod.com/harpers-plan-to-cut-canadas-old-age-security-oas-program/ clearing cache in /public_html/wordpress/wp-content/cache/supercache/www.financialgod.comhttp:/www.financialgod.com/harpers-plan-to-cut-canadas-old-age-security-oas-program/.
    13:43:12 /wordpress/wp-admin/admin-ajax.php wp_cache_post_id_gc clearing cache in /public_html/wordpress/wp-content/cache/supercache/www.financialgod.comhttp:/www.financialgod.com/harpers-plan-to-cut-canadas-old-age-security-oas-program/page/.

    Nothing actually gets cleared.

    This path also seems wrong:
    13:43:27 /wordpress/wp-admin/options-general.php?page=wpsupercache&tab=debug supercache dir: /public_html/wordpress/wp-content/cache/supercache/www.financialgod.com/wordpress/wp-admin/options-general.php/
    13:43:27 /wordpress/wp-admin/options-general.php?page=wpsupercache&tab=debug No wp-cache file exists. Must generate a new one

    I would really like my visitors to see the latest comments -- what can I do aside from disabling super cache?

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

  2. Donncha O Caoimh
    Member
    Plugin Author

    Posted 2 years ago #

    I see what's wrong but I don't know why - siteurl() is returning nothing when it's supposed to return the url of the site. Should be easy enough to fix.

  3. Donncha O Caoimh
    Member
    Plugin Author

    Posted 2 years ago #

    There's a fix in the development version for this. It's on the "Other versions" page of the plugin homepage. Can you give it a go? Enable debugging (only requires level 1 debugging) and keep an eye on the warnings..

  4. financialgod
    Member
    Posted 2 years ago #

    This version seems to work, but I do still see errors:

    19:17:44 /wordpress/wp-cron.php?doing_wp_cron=1330715863 wp_cron_preload_cache: preload cancelled
    19:18:30 /wordpress/wp-admin/admin-ajax.php get_current_url_supercache_dir: warning! site_url (http://www.financialgod.com/wordpress) not found in permalink (http://www.financialgod.com/so-you-want-to-get-a-new-job-now-what/).
    19:18:30 /wordpress/wp-admin/admin-ajax.php get_current_url_supercache_dir: Removing SERVER_NAME (www.financialgod.com) and http:// from permalink (http://www.financialgod.com/so-you-want-to-get-a-new-job-now-what/). Is the url right?

  5. financialgod
    Member
    Posted 2 years ago #

    Here is with more debugging info; it seems that it's no longer putting the "http://" in the cache file path which is good:

    19:21:32 /wordpress/wp-comments-post.php In WP Cache Phase 2
    19:21:32 /wordpress/wp-comments-post.php Setting up WordPress actions
    19:21:32 /wordpress/wp-comments-post.php Not caching POST request.
    19:21:32 /wordpress/wp-comments-post.php get_current_url_supercache_dir: warning! site_url (http://www.financialgod.com/wordpress) not found in permalink (http://www.financialgod.com/so-you-want-to-get-a-new-job-now-what/).
    19:21:32 /wordpress/wp-comments-post.php get_current_url_supercache_dir: Removing SERVER_NAME (www.financialgod.com) and http:// from permalink (http://www.financialgod.com/so-you-want-to-get-a-new-job-now-what/). Is the url right?
    19:21:32 /wordpress/wp-comments-post.php supercache dir: /home3/finanda1/public_html/wordpress/wp-content/cache/supercache/www.financialgod.com/so-you-want-to-get-a-new-job-now-what/
    19:21:32 /wordpress/wp-comments-post.php wp_cache_post_id_gc post_id: 464 http://www.financialgod.com/so-you-want-to-get-a-new-job-now-what/ clearing cache in /home3/finanda1/public_html/wordpress/wp-content/cache/supercache/www.financialgod.com/so-you-want-to-get-a-new-job-now-what/.
    19:21:32 /wordpress/wp-comments-post.php prune_super_cache: wp_cache_rebuild_or_delete( /home3/finanda1/public_html/wordpress/wp-content/cache/supercache/www.financialgod.com/so-you-want-to-get-a-new-job-now-what/index.html.gz )
    19:21:32 /wordpress/wp-comments-post.php rebuild_or_gc: rename to /home3/finanda1/public_html/wordpress/wp-content/cache/supercache/www.financialgod.com/so-you-want-to-get-a-new-job-now-what/index.html.gz.needs-rebuild
    19:21:32 /wordpress/wp-comments-post.php prune_super_cache: wp_cache_rebuild_or_delete( /home3/finanda1/public_html/wordpress/wp-content/cache/supercache/www.financialgod.com/so-you-want-to-get-a-new-job-now-what/index.html )
    19:21:32 /wordpress/wp-comments-post.php rebuild_or_gc: rename to /home3/finanda1/public_html/wordpress/wp-content/cache/supercache/www.financialgod.com/so-you-want-to-get-a-new-job-now-what/index.html.needs-rebuild
    19:21:32 /wordpress/wp-comments-post.php wp_cache_post_id_gc clearing cache in /home3/finanda1/public_html/wordpress/wp-content/cache/supercache/www.financialgod.com/so-you-want-to-get-a-new-job-now-what//page/.
    19:21:32 /wordpress/wp-comments-post.php wp_cache_post_id_gc clearing cache in /home3/finanda1/public_html/wordpress/wp-content/cache/supercache/www.financialgod.com//page/.
    19:21:32 /wordpress/wp-comments-post.php Post change: deleting cache files in /home3/finanda1/public_html/wordpress/wp-content/cache/supercache/www.financialgod.com/
    19:21:32 /wordpress/wp-comments-post.php Post 464 changed. Update cache.

  6. Donncha O Caoimh
    Member
    Plugin Author

    Posted 2 years ago #

    Good, so my changes are working! :)

  7. oreio
    Member
    Posted 2 years ago #

    Hello, I have the exact same problem described by the OP.

    WordPress 3.3.1, WP Super Cache 1.0

    I did not test the devel version, but here in 1.0 my dirty fix here was changing from site_url to home_url in wp-cache-phase1.php.

    From:

    $uri = str_replace( site_url(), '', get_permalink( $post_id ) );

    To:

    $uri = str_replace( home_url(), '', get_permalink( $post_id ) );

    I don't know if that will break other functionality, but now the new comments wipe the current cache for the page.

    I guess the problem is because we're not using the wordpress files in the root of the domain. The OP installed WordPress in the 'wordpress' folder, and myself inside the 'wp' folder. Note that these folders do not appear in the site URL.

    From my wp-config.php file:

    define('WP_HOME', 'http://aurelio.net');       // home, index
    define('WP_SITEURL', 'http://aurelio.net/wp'); // WP dir

    As far as I can tell, the "new comment updates the post cache" is the only WP Super Cache feature that is not working in my non-standard WordPress install, everything else works fine.

  8. Nikos M.
    Member
    Posted 2 years ago #

    i have the same problem in my blog
    http://nikos-web-development.netai.net/blog/

    wordpress is installed in subdirectory blog/
    and the page/post is not refreshed when comment made

    the blog/ subidrectory does not appear in the $uri parameter

    although the cache folder structure contains the blog/subdirectory

    changing from site_url to home_url does not fix it either.

    thanx

  9. Nikos M.
    Member
    Posted 2 years ago #

    The problem is inside get_current_url_supercache_dir function
    in wp-cache-phase1.php in line

    $dir = preg_replace( '/:.*$/', '',  $_SERVER["HTTP_HOST"] ) . $uri; // To avoid XSS attacks

    This works only for installations at the root folder

    a fix would be to have the function get_supercache_dir to build the dir
    inside this function

    i can fix that but it is better for evryone to know especially the developer

  10. Nikos M.
    Member
    Posted 2 years ago #

    a fix can be this that works on every installation

    //$dir = preg_replace( '/:.*$/', '',  $_SERVER["HTTP_HOST"] ) . $uri; // To avoid XSS attacks
    	$dir = preg_replace( $uri, '',  $_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"] ).$uri;
    	$dir = preg_replace( '/:.*$/', '',  $dir ); // To avoid XSS attacks
  11. oreio
    Member
    Posted 2 years ago #

    Nikos, I guess in your case, WordPress installation (site_url) and the homepage (home_url), both as set to /blog, so changing that line in wp-cache-phase1.php won't make a difference.

    My fix does not work for you and your fix is not necessary for me. Let's hope in the next version of the plugin Donncha will manage to fix both cases :)

  12. Nikos M.
    Member
    Posted 2 years ago #

    actually the fix i posted is not correct.
    sorry i checked it and it is not correct

    the problem is to get the installation url
    that works with the permalinks

  13. Nikos M.
    Member
    Posted 2 years ago #

    this is thecorect fix that worked for me
    the problem is to have super cache take the correct url even if not on root folder for refreshing after comment this i find to work perfectly so far regardless of root or not

    if ( $post_id != 0 ) {
    		$uri = str_replace( site_url(), '', get_permalink( $post_id ) );
    		$dirprefix=true;
    	} else {
    		$uri = strtolower( $wp_cache_request_uri );
    		$dirprefix=false;
    	}
    	$uri = preg_replace('/[ <>\'\"\r\n\t\(\)]/', '', str_replace( '/index.php', '/', str_replace( '..', '', preg_replace("/(\?.*)?$/", '', $uri ) ) ) );
    	$uri = str_replace( '\\', '', $uri );
    	if ($dirprefix)
    		$dir = str_replace( 'http://', '',  site_url() ) . $uri; // To avoid XSS attacks
    	else
    		$dir = preg_replace( '/:.*$/', '',  $_SERVER["HTTP_HOST"] ) . $uri; // To avoid XSS attacks
  14. Donncha O Caoimh
    Member
    Plugin Author

    Posted 2 years ago #

    Nikos M. - did you try the development version? I fixed this problem in that version. http://downloads.wordpress.org/plugin/wp-super-cache.zip

  15. Nikos M.
    Member
    Posted 2 years ago #

    if this is alraedy fixed, i'm sorry, as i only check release versions
    generally i dont check dev versions.
    why dont you release an update for everyone to be able to update correctly

    anyway i solved my issue

    thanx for a nice and usefull plugin.

  16. Donncha O Caoimh
    Member
    Plugin Author

    Posted 2 years ago #

    Try the development version. I think problems with WP in a folder may be fixed now.

    http://ocaoimh.ie/y/2o

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic