Skip to content

Commit 73a107e

Browse files
committed
Move all compression configs under Compression
Create subsection under `Compression` to allow users to more easily mark certain resources as been compressed in order to: 1) ensure that they are served with the `Content-Encoding: gzip` HTTP response header 2) prevent Apache from recompressing them (see: https://github.com/apache/httpd/blob/53823ebd5c93b34995a46ccdad2f84b4f4128cd0/modules/filters/mod_deflate.c#L593-L596)
1 parent d34336a commit 73a107e

File tree

4 files changed

+39
-10
lines changed

4 files changed

+39
-10
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
### HEAD
2+
3+
* Move all compression related configs under the `Compression` section.
4+
15
### 2.4.1 (June 7, 2014)
26

37
* Improve and update inline comments.

src/.htaccess

+21-8
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,7 @@ Options -MultiViews
195195
AddType application/x-font-ttf ttc ttf
196196
AddType font/opentype otf
197197

198-
# Make SVGZ fonts work on the iPad.
199-
# https://twitter.com/FontSquirrel/status/14855840545
200-
201198
AddType image/svg+xml svg svgz
202-
AddEncoding gzip svgz
203199

204200
# Other
205201
AddType application/octet-stream safariextz
@@ -556,17 +552,34 @@ AddDefaultCharset utf-8
556552

557553
# Force compression for mangled headers.
558554
# https://developer.yahoo.com/blogs/ydn/pushing-beyond-gzipping-25601.html
555+
559556
<IfModule mod_setenvif.c>
560557
<IfModule mod_headers.c>
561558
SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
562559
RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
563560
</IfModule>
564561
</IfModule>
565562

566-
# Compress all output labeled with one of the following media types
567-
# (for Apache versions below 2.3.7, you don't need to enable `mod_filter`
568-
# and can remove the `<IfModule mod_filter.c>` and `</IfModule>` lines
569-
# as `AddOutputFilterByType` is still in the core directives).
563+
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
564+
565+
# Mark certain resources as been compressed in order to:
566+
#
567+
# 1) prevent Apache from recompressing them
568+
# 2) ensure that they are served with the
569+
# `Content-Encoding: gzip` HTTP response header
570+
571+
<IfModule mod_mime.c>
572+
AddEncoding gzip svgz
573+
</IfModule>
574+
575+
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
576+
577+
# Compress all output labeled with one of the following media types.
578+
579+
# IMPORTANT: For Apache versions below 2.3.7 you don't need to enable
580+
# `mod_filter` and can remove the `<IfModule mod_filter.c>` & `</IfModule>`
581+
# lines as `AddOutputFilterByType` is still in the core directives.
582+
570583
<IfModule mod_filter.c>
571584
AddOutputFilterByType DEFLATE application/atom+xml \
572585
application/javascript \

test/fixtures/content/.htaccess

+14-2
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,11 @@ ErrorDocument 404 /404.html
119119
# Web fonts
120120
AddType application/font-woff woff
121121
AddType application/vnd.ms-fontobject eot
122+
122123
AddType application/x-font-ttf ttc ttf
123124
AddType font/opentype otf
124125

125126
AddType image/svg+xml svg svgz
126-
AddEncoding gzip svgz
127127

128128
# Other
129129
AddType application/octet-stream safariextz
@@ -294,14 +294,26 @@ AddDefaultCharset utf-8
294294
<IfModule mod_deflate.c>
295295

296296
# Force compression for mangled headers.
297+
297298
<IfModule mod_setenvif.c>
298299
<IfModule mod_headers.c>
299300
SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
300301
RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
301302
</IfModule>
302303
</IfModule>
303304

304-
# Compress all output labeled with one of the following media types
305+
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
306+
307+
# Mark certain resources as been compressed.
308+
309+
<IfModule mod_mime.c>
310+
AddEncoding gzip svgz
311+
</IfModule>
312+
313+
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
314+
315+
# Compress all output labeled with one of the following media types.
316+
305317
<IfModule mod_filter.c>
306318
AddOutputFilterByType DEFLATE application/atom+xml \
307319
application/javascript \

test/fixtures/content/test.svgz

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)