| @@ -91,10 +91,16 @@ | ||
| 91 | 91 | |
| 92 | 92 | // Apache htaccess cache rules (skip on LiteSpeed — remove any existing rules) |
| 93 | 93 | add_action('berqwp_activate_plugin', 'bwp_write_htaccess_rules'); |
| 94 | 94 | add_action('berqwp_flush_all_cache', 'bwp_write_htaccess_rules'); |
| 95 | + add_action('berqwp_flush_all_cache', 'bwp_delete_php_files_in_cache'); | |
| 95 | 96 | add_action('berqwp_deactivate_plugin', 'bwp_remove_htaccess_rules'); |
| 96 | 97 | |
| 98 | + // Keep the dropin's cached permalink convention in sync with WordPress | |
| 99 | + add_action('init', 'bwp_sync_permalink_config'); | |
| 100 | + add_action('update_option_permalink_structure', 'bwp_sync_permalink_config'); | |
| 101 | + add_action('berqwp_activate_plugin', 'bwp_sync_permalink_config'); | |
| 102 | + | |
| 97 | 103 | if (bwp_is_openlitespeed_server()) { |
| 98 | 104 | add_action('berqwp_activate_plugin', 'bwp_remove_htaccess_rules'); |
| 99 | 105 | } |
| 100 | 106 | |
| @@ -181,8 +187,11 @@ | ||
| 181 | 187 | $berq_log->info("Processing updates"); |
| 182 | 188 | |
| 183 | 189 | self::stale_cloud_assets(); |
| 184 | 190 | $this->purge_critical_css_cache(); |
| 191 | + | |
| 192 | + // trigger cache warmup | |
| 193 | + do_action('berqwp_cache_warmup'); | |
| 185 | 194 | |
| 186 | 195 | } |
| 187 | 196 | |
| 188 | 197 | static function stale_cloud_assets() { |
| @@ -934,8 +943,18 @@ | ||
| 934 | 943 | self::miss_cache_headers(); |
| 935 | 944 | return; |
| 936 | 945 | } |
| 937 | 946 | |
| 947 | + | |
| 948 | + // Redirect non-canonical URLs (wrong trailing slash) the same way WordPress would, | |
| 949 | + // before ever touching the cache — works for both trailing-slash and non-trailing-slash | |
| 950 | + // permalink structures. | |
| 951 | + $canonical_url = bwp_canonicalize_page_url($page_url); | |
| 952 | + if ($canonical_url !== $page_url) { | |
| 953 | + wp_safe_redirect($canonical_url, 301); | |
| 954 | + exit(); | |
| 955 | + } | |
| 956 | + | |
| 938 | 957 | if (is_singular()) { |
| 939 | 958 | $post_type = get_post_type(); |
| 940 | 959 | |
| 941 | 960 | if (empty($post_type) || !in_array($post_type, get_option('berqwp_optimize_post_types'))) { |
| @@ -1001,9 +1020,9 @@ | ||
| 1001 | 1020 | // Prevent PHP/Apache from re-compressing the already-gzipped cache file |
| 1002 | 1021 | if (ini_get('zlib.output_compression')) { |
| 1003 | 1022 | ini_set('zlib.output_compression', 'Off'); |
| 1004 | 1023 | } |
| 1005 | - | |
| 1024 | + | |
| 1006 | 1025 | while (ob_get_level()) { |
| 1007 | 1026 | ob_end_clean(); |
| 1008 | 1027 | } |
| 1009 | 1028 | |