• How to solve the pagination cache problem? For example, https://example.com/page/2/ will be cached forever and the content will never be updated even you had added new posts unless you clear the cloudflare cache manually. I had checked that the category archive pagination work fine which it will auto clear the category archive pagination when you add new posts under that specific category but not for the homepage pagination eg /page/2/ /page/3/ …

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor iSaumya

    (@isaumya)

    This seems like a theme issue or rather more specifically your setup issue.

    You see you can have paginations anywhere you want. But the plugin only look for the following things when it purge cache for the related pages:

    1. The home page (not any paginations under it)
    2. The blog page (including all paginations) – This is the page where all your blog items are shown. Like for example if you have select your home page to be latest posts from WP Settings > Reading section.
    OR maybe you have selected a separate page as home page and a separate page as blog page
    Screenshot: https://i.imgur.com/3vTj9kk.png
    3. Post Archive pages (e.g. category, tags etc.) – incl. paginations

    Now without knowing how your website has been setup it is very hard to tell why it is happening to you.

    Thread Starter infinitymusics

    (@infinitymusics)

    Hi, i think it is the codings issue as you had mentioned that it only purge 1. The home page (not any paginations under it) , so it means it will never purge the page eg. https://example.com/page/2/, https://example.com/page/3/, https://example.com/page/4/, https://example.com/page/5/

    I had customized the codings in so it will works for purging the home page and paginations under it.

    In my functions.php, i add extra count total posts function.
    // Count total posts.
    function count_total_posts() {
    $count_post = wp_cache_get(‘count_all_post’);

    if ($count_post === false) {
    $count_post = wp_count_posts()->publish;
    wp_cache_set(‘count_all_post’, $count_post);
    }

    return $count_post;
    }

    In /wp-content/plugins/wp-cloudflare-page-cache/libs/cache_controller.class.php
    start from lines: 1113
    // Purge the home page as well if SWCFPC_HOME_PAGE_SHOWS_POSTS set to true
    if( defined( ‘SWCFPC_HOME_PAGE_SHOWS_POSTS’ ) && SWCFPC_HOME_PAGE_SHOWS_POSTS === true ) {
    array_push($listofurls, home_url(‘/’));

    // Changes
    if( $this->main_instance->get_single_config(‘cf_post_per_page’, 0) > 0 ) {
    $post_count = count_total_posts();
    $post_pages_number = ceil($post_count / $this->main_instance->get_single_config(‘cf_post_per_page’, 0) );

    for ($j=2; $j<=$post_pages_number; $j++) {
    $home_paginated_url = home_url(‘/page/’) . user_trailingslashit($j);
    array_push($listofurls, $home_paginated_url);
    }
    }
    }

    So it will work for purging the homepage as well as the pagination under it.

    @isaumya Do you have any suggestion for the codings and how can I improve it?

    Plugin Contributor iSaumya

    (@isaumya)

    Hi,
    There is a filter named swcfpc_post_related_url_init check the FAQ tab under the plugin settings on more details about it.

    You can use that filter to pass the list of paginated home page URLs so that when the system purge related pages it also purge those URLs.

    You don’t need to overwrite the plugin files as that would give you devastating effect when the plugin is updated. Rather use the swcfpc_post_related_url_init filter.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to solve the pagination cache problem?’ is closed to new replies.