diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -2720,6 +2720,7 @@ 'PhabricatorVeryWowEnglishTranslation' => 'infrastructure/internationalization/translation/PhabricatorVeryWowEnglishTranslation.php', 'PhabricatorViewerDatasource' => 'applications/people/typeahead/PhabricatorViewerDatasource.php', 'PhabricatorWatcherHasObjectEdgeType' => 'applications/transactions/edges/PhabricatorWatcherHasObjectEdgeType.php', + 'PhabricatorWebServerSetupCheck' => 'applications/config/check/PhabricatorWebServerSetupCheck.php', 'PhabricatorWordPressAuthProvider' => 'applications/auth/provider/PhabricatorWordPressAuthProvider.php', 'PhabricatorWorker' => 'infrastructure/daemon/workers/PhabricatorWorker.php', 'PhabricatorWorkerActiveTask' => 'infrastructure/daemon/workers/storage/PhabricatorWorkerActiveTask.php', @@ -6189,6 +6190,7 @@ 'PhabricatorVeryWowEnglishTranslation' => 'PhutilTranslation', 'PhabricatorViewerDatasource' => 'PhabricatorTypeaheadDatasource', 'PhabricatorWatcherHasObjectEdgeType' => 'PhabricatorEdgeType', + 'PhabricatorWebServerSetupCheck' => 'PhabricatorSetupCheck', 'PhabricatorWordPressAuthProvider' => 'PhabricatorOAuth2AuthProvider', 'PhabricatorWorkerActiveTask' => 'PhabricatorWorkerTask', 'PhabricatorWorkerArchiveTask' => 'PhabricatorWorkerTask', diff --git a/src/applications/config/check/PhabricatorWebServerSetupCheck.php b/src/applications/config/check/PhabricatorWebServerSetupCheck.php new file mode 100644 --- /dev/null +++ b/src/applications/config/check/PhabricatorWebServerSetupCheck.php @@ -0,0 +1,45 @@ +setPath('/status/'); + + // If `phabricator.base-uri` is not set then we can't really do anything. + if (!$base_uri) { + return; + } + + // Make sure that we don't recursively call the setup check. + if (AphrontRequest::getHTTPHeader('X-Phabricator-Setup-Check')) { + return; + } + + $future = id(new HTTPSFuture($base_uri)) + ->addHeader('Accept-Encoding', 'gzip') + ->addHeader('X-Phabricator-Setup-Check', true) + ->setTimeout(5); + + list($status, $body, $headers) = $future->resolve(); + + if (BaseHTTPFuture::getHeader($headers, 'Content-Encoding') != 'gzip') { + $this->newIssue('webserver.gzip') + ->setName(pht('Enable gzip compression')) + ->setMessage( + pht( + 'All modern browsers support and automatically negotiate gzip '. + 'compression for all HTTP requests. Enabling gzip compression '. + 'can reduce the size of the transferred response by up to 90%%, '. + 'which can significantly reduce the amount of time to download '. + 'the resource, reduce data usage for the client, and improve '. + 'the time to first render of your pages.')); + } + } + +}