Describe the bug
My site has some 300K pages, it is very old, and without cache page load is very slow. So, I noticed that sometimes pages are not loaded to cache completely. This means that html in cached file is broken (half of page is missing). I think that due to some timeout or when the page load is extremely slow, page is not loaded completely. And this may happen, that such page version can go to cache.
Apart from load speed problems on my site, the problem is, that page integrity in buffer is never checked.
Here is part of your function maybe_process_buffer from class-cache.php
public function maybe_process_buffer( $buffer ) {
if ( ! $this->tests->can_process_buffer( $buffer ) ) {
$this->log_last_test_error();
return $buffer;
}
$footprint = '';
$is_html = $this->is_html( $buffer );
if ( ! static::can_generate_caching_files() ) {
// Not allowed to generate cache files.
if ( $is_html ) {
$footprint = $this->get_rocket_footprint();
}
$this->log(
'Page not cached by filter.',
[
'filter' => 'do_rocket_generate_caching_files',
]
);
return $buffer . $footprint;
}
$cache_filepath = $this->get_cache_path();
$cache_dir_path = dirname( $cache_filepath );
// Create cache folders.
rocket_mkdir_p( $cache_dir_path );
if ( $is_html ) {
$footprint = $this->get_rocket_footprint( time() );
}
// Save the cache file.
rocket_put_content( $cache_filepath, $buffer . $footprint );
//... rest of code
}
$is_html reflects html integrity but is not used to stop caching if there is no closing