| @@ -39,8 +39,37 @@ | ||
| 39 | 39 | 'custom_panel' => 'PreloaderHost', |
| 40 | 40 | ); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | + /** | |
| 44 | + * Surface a firewall refusing our warmer. | |
| 45 | + * | |
| 46 | + * A 403/406 on a warm used to reach the admin only as "HTTP 403" buried | |
| 47 | + * in the activity log, so a site whose every warm was refused looked | |
| 48 | + * simply idle — newly published posts were never warmed and nothing said | |
| 49 | + * why. The page is fine; the fix is a server rule, so the notice names | |
| 50 | + * the user-agent to allow. (#481) | |
| 51 | + */ | |
| 52 | + public function ui_notices(): array { | |
| 53 | + $block = Preloader::firewall_block(); | |
| 54 | + if ( null === $block ) { | |
| 55 | + return array(); | |
| 56 | + } | |
| 57 | + | |
| 58 | + return array( | |
| 59 | + array( | |
| 60 | + 'tone' => 'warn', | |
| 61 | + 'title' => __( 'Your server is blocking the xSpeed cache warmer', 'xspeed' ), | |
| 62 | + 'body' => sprintf( | |
| 63 | + /* translators: 1: HTTP status code, 2: the user-agent xSpeed sends. */ | |
| 64 | + __( 'A warm request was refused with HTTP %1$d, which is how a firewall answers when it judges a request by its user-agent. Pages are not being warmed, so the first visitor to each new page waits for an uncached render. Allow the user-agent "%2$s" in your server\'s bad-bot rules — on xCloud this is the 8G firewall — or change it with the xspeed_preloader_user_agent filter. This notice clears itself once a warm gets through.', 'xspeed' ), | |
| 65 | + (int) $block['code'], | |
| 66 | + (string) ( $block['user_agent'] ?? Preloader::user_agent() ) | |
| 67 | + ), | |
| 68 | + ), | |
| 69 | + ); | |
| 70 | + } | |
| 71 | + | |
| 43 | 72 | public function settings_schema(): array { |
| 44 | 73 | return array( |
| 45 | 74 | 'enabled' => array( |
| 46 | 75 | 'type' => 'bool', |