• I want to have some specific pages get purged from the cache when posts are updated….for example, I have a page that features a blog gallery. When a new blog entry is written, this page doesn’t display the new blog entry until it’s flushed from the page cache.

    Do I specify this page in the “additional pages” section of the purge policy in the page cache?

    Or is there another way to accomplish this?

    Thanks!

    https://www.ads-software.com/plugins/w3-total-cache/

Viewing 7 replies - 1 through 7 (of 7 total)
  • I have the same issue…

    I have about 25 pages set up as ‘additional pages’ that I want purged and recreated whenever a new post in published (they all display grids of posts sorted by category/tag etc), but it’s not happening.

    This is the format I’m using in the ‘additional pages’ box…

    https://edgazette.co.uk/early-years
    https://edgazette.co.uk/primary
    https://edgazette.co.uk/secondary

    Does this work separately to the cache preload settings or are they somehow tied together?

    Many thanks,

    Chris.

    P.S. All works incredibly fast once the cache for a page is in place…brilliant performance!

    Thread Starter jacobstone

    (@jacobstone)

    @chrishdunn does that format in the “additional pages” box seem to work for getting those pages purged upon updates to posts/pages?

    @jacobstone … no it doesn’t…not sure if the format is the problem or something else. Preloading isn’t working properly either. Am investigating with my host at the moment.

    Thread Starter jacobstone

    (@jacobstone)

    Thanks for the update – would love to hear more if you get this figured out! Thanks for your reply.

    Trying to get this functionality working as well. From my investigation, you should just be able to add the pages in the following format:

    /page-slug/
    /page-slug/sub-page/

    Has anyone been able to get this functionality working? Any thoughts @amiga500 ?

    • This reply was modified 8 years, 2 months ago by stevesearer.

    I moved to WP Rocket cache.

    Also managed to write some code to cover purging…I have the code below in my functions.php …
    This is specific to WP Rocket, but the point is that you can use the ‘publish_post’ hook to delete your cache files. Pre-loading would be a different issue though! (I have this covered in WP Rocket)

    add_action( ‘publish_post’, ‘example_publish_post’ );
    function example_publish_post(){

    $homepath = get_home_path();

    $path = $homepath . ‘/wp-content/cache/yourpath/yoursite.co.uk/’ ;

    $filestopurge = array(

    $path . ‘index.html’,
    $path . ‘index.html_gzip’,
    $path . ‘/early-years/index.html’,
    $path . ‘/early-years/index.html_gzip’,
    $path . ‘/primary/index.html’,
    $path . ‘/primary/index.html_gzip’,
    $path . ‘/secondary/index.html’,
    $path . ‘/secondary/index.html_gzip’,
    $path . ‘/further-education/index.html’,
    $path . ‘/further-education/index.html_gzip’,
    $path . ‘/higher-education/index.html’,
    $path . ‘/higher-education/index.html_gzip’,
    $path . ‘/dfe/index.html’,
    $path . ‘/dfe/index.html_gzip’,
    $path . ‘/ofsted/index.html’,
    $path . ‘/ofsted/index.html_gzip’,
    $path . ‘/sta/index.html’,
    $path . ‘/sta/index.html_gzip’,
    $path . ‘/topics/index.html’,
    $path . ‘/topics/index.html_gzip’,
    $path . ‘/subjects/index.html’,
    $path . ‘/subjects/index.html_gzip’,
    $path . ‘/ofqual/index.html’,
    $path . ‘/ofqual/index.html_gzip’,
    $path . ‘/unions/index.html’,
    $path . ‘/unions/index.html_gzip’,
    $path . ‘/blogs/index.html’,
    $path . ‘/blogs/index.html_gzip’,
    $path . ‘/qaa/index.html’,
    $path . ‘/qaa/index.html_gzip’,
    $path . ‘/hefce/index.html’,
    $path . ‘/hefce/index.html_gzip’,
    $path . ‘/exam-boards/index.html’,
    $path . ‘/exam-boards/index.html_gzip’,
    $path . ‘/northern-ireland/index.html’,
    $path . ‘/northern-ireland/index.html_gzip’,
    $path . ‘/scotland/index.html’,
    $path . ‘/scotland/index.html_gzip’,
    $path . ‘/wales/index.html’,
    $path . ‘/wales/index.html_gzip’,
    $path . ‘/efa/index.html’,
    $path . ‘/efa/index.html_gzip’,

    ) ;

    foreach ($filestopurge as $purgefile) {
    if (file_exists($purgefile)) {
    unlink($purgefile);
    }
    }

    Ah nice, just adjusted your code for a quick w3tc demo which I was able to get working on edit_post. For some reason get_home_path() didn’t work for me and I had to use ABSPATH.

    add_action( 'edit_post', 'example_publish_post' );
    
    function example_publish_post(){
    
        $homepath = ABSPATH;
        $path = $homepath . 'wp-content/cache/page_enhanced/localhost/';
    
        $filestopurge = array(
            $path . 'contact/_index.html',
            $path . 'contact/_index.html_gzip'
        );
    
        foreach($filestopurge as $purgefile) {
            if (file_exists($purgefile)) {
                @unlink($purgefile);
            }
        }
    
    }
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Format of "additional pages" in page cache purge policy’ is closed to new replies.