From e9e46e339119b3ae59cd840b1159c16f896c02f4 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Tue, 24 Oct 2023 20:32:35 +0900 Subject: [PATCH] Remove HTTP/2 server push for Cloudflare MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 클플에서 해당 기능 지원 중단하여 더이상 작동하지 않음 https://developer.chrome.com/blog/removing-push/ --- .../FrontEndFileHandler.class.php | 47 ------------------- common/defaults/config.php | 1 - .../controllers/systemconfig/Advanced.php | 2 - modules/admin/lang/en.php | 2 - modules/admin/lang/ja.php | 1 - modules/admin/lang/ko.php | 2 - modules/admin/tpl/config_advanced.html | 9 ---- 7 files changed, 64 deletions(-) diff --git a/classes/frontendfile/FrontEndFileHandler.class.php b/classes/frontendfile/FrontEndFileHandler.class.php index 4789a60f7..0f4271155 100644 --- a/classes/frontendfile/FrontEndFileHandler.class.php +++ b/classes/frontendfile/FrontEndFileHandler.class.php @@ -507,17 +507,6 @@ class FrontEndFileHandler extends Handler } } - // Enable HTTP/2 server push for CSS resources. - if ($finalize && $this->_isServerPushEnabled()) - { - foreach ($result as $resource) - { - if ($resource['file'][0] === '/' && $resource['file'][1] !== '/') - { - header(sprintf('Link: <%s>; rel=preload; as=style', $resource['file']), false); - } - } - } return $result; } @@ -611,17 +600,6 @@ class FrontEndFileHandler extends Handler } } - // Enable HTTP/2 server push for JS resources. - if ($type === 'head' && $finalize && $this->_isServerPushEnabled()) - { - foreach ($result as $resource) - { - if ($resource['file'][0] === '/' && $resource['file'][1] !== '/') - { - header(sprintf('Link: <%s>; rel=preload; as=script', $resource['file']), false); - } - } - } return $result; } @@ -743,29 +721,4 @@ class FrontEndFileHandler extends Handler $file->index += isset($cssSortList[$tmp]) ? $cssSortList[$tmp] : 0; } } - - /** - * Check if server push is enabled. - * - * @return bool - */ - protected function _isServerPushEnabled() - { - if (!config('view.server_push')) - { - return false; - } - elseif (strncmp($_SERVER['SERVER_PROTOCOL'] ?? '', 'HTTP/2', 6) === 0) - { - return true; - } - elseif (isset($_SERVER['HTTP_CF_VISITOR']) && \RX_SSL) - { - return true; - } - else - { - return false; - } - } } diff --git a/common/defaults/config.php b/common/defaults/config.php index e7a284ee0..30a5ffb5e 100644 --- a/common/defaults/config.php +++ b/common/defaults/config.php @@ -84,7 +84,6 @@ return array( 'concat_scripts' => 'none', 'delay_compile' => 0, 'jquery_version' => 2, - 'server_push' => false, ), 'admin' => array( 'allow' => array(), diff --git a/modules/admin/controllers/systemconfig/Advanced.php b/modules/admin/controllers/systemconfig/Advanced.php index d71b80d0a..4135a0a0f 100644 --- a/modules/admin/controllers/systemconfig/Advanced.php +++ b/modules/admin/controllers/systemconfig/Advanced.php @@ -109,7 +109,6 @@ class Advanced extends Base Context::set('minify_scripts', Config::get('view.minify_scripts')); Context::set('concat_scripts', Config::get('view.concat_scripts')); Context::set('jquery_version', Config::get('view.jquery_version')); - Context::set('use_server_push', Config::get('view.server_push')); $this->setTemplateFile('config_advanced'); } @@ -227,7 +226,6 @@ class Advanced extends Base Config::set('view.concat_scripts', $vars->concat_scripts ?: 'none'); Config::set('view.delay_compile', intval($vars->delay_template_compile)); Config::set('view.jquery_version', $vars->jquery_version == 3 ? 3 : 2); - Config::set('view.server_push', $vars->use_server_push === 'Y'); // Save if (!Config::save()) diff --git a/modules/admin/lang/en.php b/modules/admin/lang/en.php index 9a86fea46..f6f83a0d7 100644 --- a/modules/admin/lang/en.php +++ b/modules/admin/lang/en.php @@ -158,8 +158,6 @@ $lang->cmd_concat_css_js = 'Combine both CSS and JS'; $lang->about_concat_scripts = 'Automatically combine CSS and JS scripts into as few files as possible. External scripts are not combined.'; $lang->jquery_version = 'jQuery Version'; $lang->about_jquery_version = 'You can select the default jQuery version for this site. Please note that jQuery 3.x may not be compatible with older features.'; -$lang->use_server_push = 'Use HTTP/2 Server Push'; -$lang->about_use_server_push = 'This option adds headers to the response that some CDNs interpret as server push directives.'; $lang->use_gzip = 'gzip Compression'; $lang->about_use_gzip = 'This option should be left off unless you know for sure that your webserver doesn\'t compress output by default.'; $lang->delay_session = 'Delay session start'; diff --git a/modules/admin/lang/ja.php b/modules/admin/lang/ja.php index b240f8aa8..aa3840809 100644 --- a/modules/admin/lang/ja.php +++ b/modules/admin/lang/ja.php @@ -88,7 +88,6 @@ $lang->cmd_concat_css_only = 'CSSのみ結合'; $lang->cmd_concat_js_only = 'JSのみ結合'; $lang->cmd_concat_css_js = 'CSSやJSの両方を結合'; $lang->about_concat_scripts = 'CSS、JSファイルを一つにまとめて送信されます。外部からロードするスクリプトは、合わせてされません.'; -$lang->use_server_push = 'HTTP/2 Server Push使用'; $lang->use_gzip = 'gzip 圧縮'; $lang->delay_session = 'セッションの開始を遅延'; $lang->about_delay_session = 'Varnishなどのプロキシキャッシュサーバ使用時のパフォーマンスを向上させるために、ログインしていないユーザーには、認証セッションを付与しません。
このオプションを選択した場合、訪問者数とヒット集計が正確でない場合があります。'; diff --git a/modules/admin/lang/ko.php b/modules/admin/lang/ko.php index 68d082408..21829db8e 100644 --- a/modules/admin/lang/ko.php +++ b/modules/admin/lang/ko.php @@ -159,8 +159,6 @@ $lang->cmd_concat_css_js = 'CSS와 JS를 모두 합침'; $lang->about_concat_scripts = 'CSS, JS 파일들을 하나로 합쳐서 전송합니다. 외부에서 로딩하는 스크립트는 합쳐지지 않습니다.'; $lang->jquery_version = 'jQuery 버전'; $lang->about_jquery_version = '기본으로 사용할 jQuery 버전을 선택합니다. jQuery 3.x는 오래된 기능과 호환되지 않을 수 있습니다.'; -$lang->use_server_push = 'Server Push 사용'; -$lang->about_use_server_push = '일부 CDN에서 지원하는 기능으로, 미리 로딩할 스크립트 정보를 헤더에 추가합니다.'; $lang->use_gzip = 'gzip 압축'; $lang->about_use_gzip = '웹서버가 gzip을 지원하지 않더라도 페이지를 강제로 압축하는 기능입니다. 대부분의 서버에는 필요하지 않습니다.'; $lang->delay_session = '세션 시작 지연'; diff --git a/modules/admin/tpl/config_advanced.html b/modules/admin/tpl/config_advanced.html index 13c4026ce..5fbf95ea2 100644 --- a/modules/admin/tpl/config_advanced.html +++ b/modules/admin/tpl/config_advanced.html @@ -253,15 +253,6 @@

{$lang->about_jquery_version}

-
- -
- - -
-

{$lang->about_use_server_push}

-
-