Skip to content

Regression: Pagination Not Cached for Multi-Page Posts Using <!--nextpage--> Anymore #7538

@Whissi

Description

@Whissi

Describe the bug
Since Pull Request #7236 landed, WP-Rocket does no longer cache blog postings where the editor used WordPress' <--nextpage--> tag to split long posts into multiple pages. Note that is_paged() function cannot be used for that.

To Reproduce
Steps to reproduce the behavior:

  1. Create a blog posting with the following content:
Page1
<!--nextpage-->
Page2
  1. View that blog posting, i.e. open https://example.invalid/2025/07/30/hello-world/ in your browser and confirm that you only see "Page1" and that WP-Rockets creates the corresponding cache file.
  2. Now go the the second page, i.e. https://example.invalid/2025/07/30/hello-world/2/ and confirm that you only see "Page2". You will notice that WP-Rocket did not create a corresponding cache file.

This seems to solve the problem:

$current_link = $this->get_current_url();
if ( get_query_var( 'page' ) >= 2 ) {
    $post_link = trailingslashit( $post_link ) . get_query_var( 'page' );
}
elseif ( is_paged() ) {
    $post_link = trailingslashit( $post_link ) . 'page/' . get_query_var( 'paged' );
}

Not sure if this is a cheap-enough call or if you also want to make use of $GLOBALS['multipage'] which is set when <--nextpage--> was used.

Note that you are using same check code for Taxonomies, too. But I don't know at the moment if there can ever be multi-page taxonomy or not.

Do you want a Pull Request or do you want to fix it on your own?

Metadata

Metadata

Assignees

No one assigned

    Labels

    module: cachepriority: mediumIssues which are important, but no one will go out of business.type: regressionIndicates issues that have reintroduced previously fixed bugs or caused a decrease in performance

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions