WP Super Cache
function to delete homepage or category page (not post) (4 posts)

  1. Biranit
    Posted 4 years ago #


    On my site, I have some administration options that allows to manually set up the display of the posts on the homepage and the main category pages. When the editor finishes selecting the posts and formatting them, he clicks 'publish' and that generates the homepage or the specific category page he was editing.

    I wanted to add to this process an action to delete the cached version of that page. I tried simply adding do_action( 'gc_cache', 'prune', 'homepage' ) - but it did nothing. I also tried other methods that I came across in the WP Super Cache class, but they don't work. I'm obviously missing something.

    Can you point me in the right direction please?

    Many thanks,



  2. Donncha O Caoimh
    Plugin Author

    Posted 4 years ago #

    you'll probably want to do something like

    prune_super_cache( get_supercache_dir() . '/category/' . $category . '/' );

    where $category is the category you want..

  3. Biranit
    Posted 4 years ago #

    Yep, that worked. Thank you :)

    For the homepage I did:
    prune_super_cache( get_supercache_dir() . '/index.html' );
    prune_super_cache( get_supercache_dir() . '/index.html.gz' );

    I guess there's no quicker/shorter way than that?

  4. Donncha O Caoimh
    Plugin Author

    Posted 4 years ago #

    You'll probably want to use something like this too, and foreach() over the filenames as there might be more than just those 2 filenames.

    $files_to_check = get_all_supercache_filenames( $dir );

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WP Super Cache
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic