mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 01:01:41 +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;
|
||||
}
|
||||
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue