functions.php: tweak compressed page creation

This commit is contained in:
Zankaria 2025-07-29 17:36:18 +02:00
parent a6d4772db0
commit 88bb079d45

View file

@ -647,13 +647,14 @@ function file_write($path, $data, $simple = false, $skip_purge = false) {
if ($config['gzip_static']) {
$gzpath = "$path.gz";
if ($bytes & ~0x3ff) { // if ($bytes >= 1024)
if (file_put_contents($gzpath, gzencode($data), $simple ? 0 : LOCK_EX) === false)
error("Unable to write to file: $gzpath");
//if (!touch($gzpath, filemtime($path), fileatime($path)))
// error("Unable to touch file: $gzpath");
// 12KBs (2 left for headers etc) to stay within the 14 KBs of the standard initial TCP packet.
if ($bytes >= 12288) {
if (\file_put_contents($gzpath, \gzencode($data), $simple ? 0 : LOCK_EX) === false) {
// Do not fail completely if the write fails.
\error_log("Unable to write to file: $gzpath");
@unlink($gzpath);
}
else {
} else {
@unlink($gzpath);
}
}