mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-04 17:44:38 +09:00
Enable HTTP/2 server push for CSS and JS resources
This commit is contained in:
parent
4290f5110c
commit
942235b6bc
2 changed files with 25 additions and 0 deletions
|
|
@ -440,6 +440,18 @@ class FrontEndFileHandler extends Handler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Enable HTTP/2 server push for JS resources.
|
||||||
|
if ($finalize && config('view.server_push') && strncmp($_SERVER['SERVER_PROTOCOL'], 'HTTP/2', 6) === 0)
|
||||||
|
{
|
||||||
|
foreach ($result as $resource)
|
||||||
|
{
|
||||||
|
if ($resource['file'][0] === '/' && $resource['file'][1] !== '/')
|
||||||
|
{
|
||||||
|
header(sprintf('Link: <%s>; rel=preload; as=style', $resource['file']), false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -532,6 +544,18 @@ class FrontEndFileHandler extends Handler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Enable HTTP/2 server push for JS resources.
|
||||||
|
if ($finalize && config('view.server_push') && strncmp($_SERVER['SERVER_PROTOCOL'], 'HTTP/2', 6) === 0)
|
||||||
|
{
|
||||||
|
foreach ($result as $resource)
|
||||||
|
{
|
||||||
|
if ($resource['file'][0] === '/' && $resource['file'][1] !== '/')
|
||||||
|
{
|
||||||
|
header(sprintf('Link: <%s>; rel=preload; as=script', $resource['file']), false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,7 @@ return array(
|
||||||
'view' => array(
|
'view' => array(
|
||||||
'minify_scripts' => 'common',
|
'minify_scripts' => 'common',
|
||||||
'concat_scripts' => 'none',
|
'concat_scripts' => 'none',
|
||||||
|
'server_push' => false,
|
||||||
'use_gzip' => false,
|
'use_gzip' => false,
|
||||||
),
|
),
|
||||||
'admin' => array(
|
'admin' => array(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue