AddOutputFilterByType
có những hạn chế nghiêm trọng trong httpd-2.2
vì thế nó được đánh dấu phản đối đó. Nhưng trong httpd-2.4
, chỉ thị này đã được chuyển đến filter_module
, đã sửa và không được chấp nhận.
Trong apache 2.2 bạn thay vì phải kích hoạt tính năng filter_module
và deflate_module
và sử dụng:
# Declare a "gzip" filter, it should run after all internal filters like PHP or SSI
FilterDeclare gzip CONTENT_SET
# "gzip" filter can change "Content-Length", can not be used with range requests
FilterProtocol gzip change=yes;byteranges=no
# Enable "gzip" filter if "Content-Type" contains "text/html", "text/css" etc.
FilterProvider gzip DEFLATE resp=Content-Type $text/html
FilterProvider gzip DEFLATE resp=Content-Type $text/css
FilterProvider gzip DEFLATE resp=Content-Type $text/javascript
FilterProvider gzip DEFLATE resp=Content-Type $application/javascript
FilterProvider gzip DEFLATE resp=Content-Type $application/x-javascript
# Add "gzip" filter to the chain of filters
FilterChain gzip
deflate_module
sẽ chỉ phân phối nội dung nén để trình duyệt thực hiện kê khai hỗ trợ cho gzip
mã hóa trong yêu cầu tiêu đề.
này đã giúp tôi bigtime. Chỉ cần một người đứng đầu trên FilterProvider: https://github.com/h5bp/html5-boilerplate/issues/1012 – cgp
Trong Centos filter_module không được kích hoạt theo mặc định. Cần phải được uncommented. –
Điều này khiến ETags bị thiếu một cách ngẫu nhiên từ các phản hồi gzipped. – Timothy003