Support » Plugin: WP Super Cache » [WP Super Cache] Here's how to REFRESH PAGES when a new post is added/deleted

  • Unless I’ve misconfigured supercache on our installs, I’ve noticed that it does not delete additional pages (off the front page) when a new post is published or deleted.

    This means the pages are out of sync until the next cache purge for non-logged-in users.

    Here’s some code to hook a post being published or deleted and purge the pages so they are regenerated on the next viewing.

    add_action('transition_post_status', 'supercache_purge_paged', 10, 3);		
    function supercache_purge_paged($new_status, $old_status, $post) {
    	if ($post->post_type!='post' || !($new_status=='publish' || $old_status=='publish')) {return;}
    	global $cache_path; if (empty($cache_path)) {return;}
    	exec('find '.$cache_path.'supercache/*/page/ -maxdepth 0 -type d -exec rm -rf {} \;');

    WARNING: if exec is disabled on your PHP install, this code will fail, also if you aren’t on a linux system or it’s FIND is very outdated. In theory the “find” shell exec could be replaced with some much more complex PHP code to walk the directories and delete the pages but I’m not writing it, too slow.

    Because of the HTTP_HOST bug (I’ve reported elsewhere) it also has to use a wildcard to find all the various bad hostnames, which means if you have a strange rare install that uses multiple WP installs and one supercache area, all of the paged frontpages will be purged for all the installs.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Donncha O Caoimh


    Thanks. Can you give the dev version a spin? I fixed a problem with deleting /page/* last week that may solve this. It won’t fix problems with taxonomy archive pages updating though.

    Unfortunately the sites I have running supercache are too high volume to risk experimentation but I will maybe try it locally first and watch the behaviors…

    I have received a notice that after running the program I have lost all my pages, and the title to my website is gone…I keep on receiving a link to go to …and you sent me a code but where do I put the code?? please help!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[WP Super Cache] Here's how to REFRESH PAGES when a new post is added/deleted’ is closed to new replies.