gpt4 book ai didi

apache - 如何自动缩小我的网页?

转载 作者:行者123 更新时间:2023-12-04 01:37:07 25 4
gpt4 key购买 nike

我所有的 .html 和 .php 网页都应该被缩小。这意味着我希望删除所有 HTML 注释和多个空格字符。

是否存在用于缩小的 Apache 模块?
(或者也许是在输出发送给用户之前直接自动添加脚本的另一种方法?)

(我可以添加如下函数,但如果存在 Apache 模块或其他自动解决方案,我不会忘记这样做。)

<?
function sanitize_output($buffer)
{
$search = array(
'/\>[^\S ]+/s', //strip whitespaces after tags, except space
'/[^\S ]+\</s', //strip whitespaces before tags, except space
'/(\s)+/s' // shorten multiple whitespace sequences
);
$replace = array(
'>',
'<',
'\\1'
);
$buffer = preg_replace($search, $replace, $buffer);
return $buffer;
}
?>

最佳答案

试试 mod_pagespeed这可能对你有用。

关于apache - 如何自动缩小我的网页?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7606433/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com