--- a/wp-cloudflare-page-cache/assets/advanced-cache.php
+++ b/wp-cloudflare-page-cache/assets/advanced-cache.php
@@ -189,6 +189,14 @@
if ( ! file_exists( $cache_path . $cache_key ) || $swcfpc_objects['fallback_cache']->fallback_cache_is_expired_page( $cache_key ) ) {
+ // Bypass 4xx or 5xx HTTP status codes (security blocks, errors, etc.)
+ if ( SPCServicesSettings_Store::get_instance()->get( SPCConstants::SETTING_FALLBACK_CACHE_HTTP_RESPONSE_CODE ) ) {
+ $http_status = http_response_code();
+ if ( $http_status !== false && $http_status >= 400 && $http_status < 600 ) {
+ return $html;
+ }
+ }
+
if ( $sw_cloudflare_pagecache->get_single_config( 'cf_fallback_cache_ttl', 0 ) == 0 ) {
$ttl = 0;
} else {
--- a/wp-cloudflare-page-cache/bootstrap.php
+++ b/wp-cloudflare-page-cache/bootstrap.php
@@ -21,7 +21,7 @@
define( 'SWCFPC_AUTH_MODE_API_TOKEN', 1 );
define( 'SWCFPC_LOGS_STANDARD_VERBOSITY', 1 );
define( 'SWCFPC_LOGS_HIGH_VERBOSITY', 2 );
- define( 'SWCFPC_VERSION', '5.2.2' );
+ define( 'SWCFPC_VERSION', '5.2.3' );
if ( ! defined( 'SPC_METRICS_DIR' ) ) {
$home_url_parts = parse_url( home_url() );
define( 'SPC_METRICS_DIR', WP_CONTENT_DIR . "/wp-cloudflare-super-page-cache/{$home_url_parts['host']}/metrics" );
--- a/wp-cloudflare-page-cache/libs/cache_controller.class.php
+++ b/wp-cloudflare-page-cache/libs/cache_controller.class.php
@@ -1725,6 +1725,16 @@
return true;
}
+ // Bypass 4xx or 5xx HTTP status codes (security blocks, errors, etc.)
+ if ( Settings_Store::get_instance()->get( Constants::SETTING_FALLBACK_CACHE_HTTP_RESPONSE_CODE ) ) {
+ $http_status = http_response_code();
+
+ if ( $http_status !== false && $http_status >= 400 && $http_status < 600 ) {
+ Helpers::bypass_reason_header( sprintf( 'HTTP Status %d', $http_status ) );
+ return true;
+ }
+ }
+
return false;
}
--- a/wp-cloudflare-page-cache/libs/html_cache.class.php
+++ b/wp-cloudflare-page-cache/libs/html_cache.class.php
@@ -62,7 +62,7 @@
$current_url = "{$parts['scheme']}://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
if ( isset( $wp_query ) && function_exists( 'is_404' ) && is_404() ) {
- $this->main_instance->get_logger()->add_log( 'html_cache::add_current_url_to_cache', "The URL {$current_url} cannot be cached because it returns 404.", true );
+ $this->main_instance->get_logger()->add_log( 'html_cache::add_current_url_to_cache', 'The URL ' . esc_url_raw( $current_url ) . ' cannot be cached because it returns 404.', true );
return;
}
--- a/wp-cloudflare-page-cache/libs/logs.class.php
+++ b/wp-cloudflare-page-cache/libs/logs.class.php
@@ -150,7 +150,7 @@
}
if ( $_GET['swcfpc_download_log'] === 'view' ) {
- echo '<pre>' . file_get_contents( $this->log_file_path ) . '</pre>';
+ echo '<pre>' . esc_html( file_get_contents( $this->log_file_path ) ) . '</pre>';
exit;
}
--- a/wp-cloudflare-page-cache/src/Constants.php
+++ b/wp-cloudflare-page-cache/src/Constants.php
@@ -49,6 +49,7 @@
public const SETTING_OVERWRITE_WITH_HTACCESS = 'cf_cache_control_htaccess';
public const SETTING_PURGE_ONLY_HTML = 'cf_purge_only_html';
public const SETTING_DISABLE_PURGING_QUEUE = 'cf_disable_cache_purging_queue';
+ public const SETTING_FALLBACK_CACHE_HTTP_RESPONSE_CODE = 'cf_fallback_cache_http_response_code';
// Bypass Settings.
public const SETTING_BYPASS_404 = 'cf_bypass_404';
--- a/wp-cloudflare-page-cache/src/Modules/Settings_Manager.php
+++ b/wp-cloudflare-page-cache/src/Modules/Settings_Manager.php
@@ -212,6 +212,11 @@
'type' => self::SETTING_TYPE_BOOLEAN,
'default' => 0,
],
+ Constants::SETTING_FALLBACK_CACHE_HTTP_RESPONSE_CODE => [
+ 'type' => self::SETTING_TYPE_BOOLEAN,
+ 'bust_cache' => true,
+ 'default' => 1,
+ ],
Constants::SETTING_BYPASS_404 => [
'type' => self::SETTING_TYPE_BOOLEAN,
'default' => 1,
--- a/wp-cloudflare-page-cache/vendor/composer/installed.php
+++ b/wp-cloudflare-page-cache/vendor/composer/installed.php
@@ -1,9 +1,9 @@
<?php return array(
'root' => array(
'name' => 'codeinwp/wp-cloudflare-super-page-cache',
- 'pretty_version' => 'v5.2.2',
- 'version' => '5.2.2.0',
- 'reference' => '0d86bcdc77c60f1bf4049a1cc190ec6bf1291db2',
+ 'pretty_version' => 'v5.2.3',
+ 'version' => '5.2.3.0',
+ 'reference' => '9d99dd640381a4984bbe18ee96fa57e4501093c1',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
@@ -20,9 +20,9 @@
'dev_requirement' => false,
),
'codeinwp/wp-cloudflare-super-page-cache' => array(
- 'pretty_version' => 'v5.2.2',
- 'version' => '5.2.2.0',
- 'reference' => '0d86bcdc77c60f1bf4049a1cc190ec6bf1291db2',
+ 'pretty_version' => 'v5.2.3',
+ 'version' => '5.2.3.0',
+ 'reference' => '9d99dd640381a4984bbe18ee96fa57e4501093c1',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
--- a/wp-cloudflare-page-cache/wp-cloudflare-super-page-cache.php
+++ b/wp-cloudflare-page-cache/wp-cloudflare-super-page-cache.php
@@ -3,7 +3,7 @@
* Plugin Name: Super Page Cache
* Plugin URI: https://wordpress.org/plugins/wp-cloudflare-page-cache/
* Description: A WordPress performance plugin that lets you get Edge Caching enabled on a Cloudflare free plan.
- * Version: 5.2.2
+ * Version: 5.2.3
* Author: Themeisle
* Author URI: https://themeisle.com
* License: GPLv2 or later