diff --git a/classes/frontendfile/FrontEndFileHandler.class.php b/classes/frontendfile/FrontEndFileHandler.class.php index 2f2c27408..18a5ebbc7 100644 --- a/classes/frontendfile/FrontEndFileHandler.class.php +++ b/classes/frontendfile/FrontEndFileHandler.class.php @@ -442,7 +442,7 @@ class FrontEndFileHandler extends Handler } // Enable HTTP/2 server push for CSS resources. - if ($finalize && config('view.server_push') && strncmp($_SERVER['SERVER_PROTOCOL'], 'HTTP/2', 6) === 0) + if ($finalize && $this->_isServerPushEnabled()) { foreach ($result as $resource) { @@ -546,7 +546,7 @@ class FrontEndFileHandler extends Handler } // Enable HTTP/2 server push for JS resources. - if ($type === 'head' && $finalize && config('view.server_push') && strncmp($_SERVER['SERVER_PROTOCOL'], 'HTTP/2', 6) === 0) + if ($type === 'head' && $finalize && $this->_isServerPushEnabled()) { foreach ($result as $resource) { @@ -667,6 +667,31 @@ class FrontEndFileHandler extends Handler $cssSortList = array('common' => -100000, 'layouts' => -90000, 'modules' => -80000, 'widgets' => -70000, 'addons' => -60000); $file->index = $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; + } + } } /* End of file FrontEndFileHandler.class.php */ /* Location: ./classes/frontendfile/FrontEndFileHandler.class.php */