January 19, 2010 by Thibault D
This snippet will only work with apache2 servers.
Bandwidth has a cost, and performances matters.
By default, Diem minifies and combines all your javascript and stylesheet files. This reduces dramatically the number of requests required to display a page.
But we can go even farther.
You can enable gzip compression for javacript and stylesheet files. It reduces their weight by three to four times.
Just change an option on Diem javascript and stylesheet compressors to make them produce gziped files.
config/dm/services.yml
parameters:
javascript_compressor.options:
gz_compression: true
stylesheet_compressor.options:
gz_compression: true
Now, we will tell apache to forward requests to a .css or .js to the gzipped file, if any.
web/.htaccess, uncomment the lines between
# SEND GZIPPED CONTENT TO COMPATIBLE BROWSERS
and
# END GZIPPED CONTENT
You should now have:
# SEND GZIPPED CONTENT TO COMPATIBLE BROWSERS
RemoveType .gz
RemoveOutputFilter .css .js
AddEncoding x-gzip .gz
AddType "text/css;charset=utf-8" .css
AddType "text/javascript;charset=utf-8" .js
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteCond %{REQUEST_FILENAME}.gz -f
RewriteRule ^(.*)$ $1.gz [L,QSA]
# END GZIPPED CONTENT
Open a page of your website and inspect requests with firebug. The server now sends gzipped assets, and load time is reduced.
This tip will not work on all servers, depending on apache configuration.
gohpwxaoJuly 3, 2013 1:17 AM
<img>http://i.jootix.com/t/Jootix--c18dca3bcd_big.jpg </img>
и Здравствуйте. 7 дней назад мне поставили укол "кардиомин" в левую ягодицу в этот же день образовался синяк сейчас на этом месте образовалась внутренняя шишка <a href=http://greenfree.ru/xiru/66015-chto-delat.html>что делать????</a>