mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-08 04:22:40 +00:00
Don't set content-length when serving assets.
Setting content-length on assets causes long pauses when fetching assets that contain PHP code. These assets are invariably larger than their response bodies. By not setting a content-length, we can allow the webserver to calculate it for us. Refs #4916
This commit is contained in:
parent
843ddd6d36
commit
a65354225e
2 changed files with 37 additions and 3 deletions
|
@ -149,12 +149,11 @@ class AssetDispatcher extends DispatcherFilter {
|
|||
}
|
||||
$response->type($contentType);
|
||||
}
|
||||
if (!$compressionEnabled) {
|
||||
$response->header('Content-Length', filesize($assetFile));
|
||||
}
|
||||
$response->length(false);
|
||||
$response->cache(filemtime($assetFile));
|
||||
$response->send();
|
||||
ob_clean();
|
||||
|
||||
if ($ext === 'css' || $ext === 'js') {
|
||||
include $assetFile;
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue