"GET /Symfony/web/app.php/app/dashboard HTTP/1.1" 4513/37979 (11%)
"GET /Symfony/web/css/application.css HTTP/1.1" -/- (-%)
"GET /Symfony/web/js/application.js HTTP/1.1" -/- (-%)
"GET /Symfony/web/js/highcharts.js HTTP/1.1" -/- (-%)
"GET /Symfony/app/Resources/public/img/logo.png HTTP/1.1" -/- (-%)
不知道我的配置是否有问题,但是没有对 css 和 js 进行压缩,这看起来很奇怪大部头书。
但是 css 和 js 都已经最小化了。这是 cong/httpd.conf 中 Apache 的相关部分:
# Deflate
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
DeflateCompressionLevel 9
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# IE5.x and IE6 get no gzip, but allow 7+
BrowserMatch \bMSIE\s7 !no-gzip
Header append Vary User-Agent env=!dont-vary
DeflateFilterNote Input instream
DeflateFilterNote Output outstream
DeflateFilterNote Ratio ratio
LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
CustomLog logs/deflate.log deflate
答案1
也设置你的 .htaccess。这只是示例:
<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary
#Dealing with proxy servers
<IfModule mod_headers.c>
Header append Vary User-Agent
</IfModule>
</IfModule>