Skip to content

Commit

Permalink
Move all compression configs under Compression
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
alrra committed Jun 13, 2014
1 parent d34336a commit 73a107e
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### HEAD

* Move all compression related configs under the `Compression` section.

### 2.4.1 (June 7, 2014)

* Improve and update inline comments.
Expand Down
29 changes: 21 additions & 8 deletions src/.htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,7 @@ Options -MultiViews
AddType application/x-font-ttf ttc ttf
AddType font/opentype otf

# Make SVGZ fonts work on the iPad.
# https://twitter.com/FontSquirrel/status/14855840545

AddType image/svg+xml svg svgz
AddEncoding gzip svgz

# Other
AddType application/octet-stream safariextz
Expand Down Expand Up @@ -556,17 +552,34 @@ AddDefaultCharset utf-8

# Force compression for mangled headers.
# https://developer.yahoo.com/blogs/ydn/pushing-beyond-gzipping-25601.html

<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
</IfModule>
</IfModule>

# Compress all output labeled with one of the following media types
# (for Apache versions below 2.3.7, you don't need to enable `mod_filter`
# and can remove the `<IfModule mod_filter.c>` and `</IfModule>` lines
# as `AddOutputFilterByType` is still in the core directives).
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

# Mark certain resources as been compressed in order to:
#
# 1) prevent Apache from recompressing them
# 2) ensure that they are served with the
# `Content-Encoding: gzip` HTTP response header

<IfModule mod_mime.c>
AddEncoding gzip svgz
</IfModule>

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

# Compress all output labeled with one of the following media types.

# IMPORTANT: For Apache versions below 2.3.7 you don't need to enable
# `mod_filter` and can remove the `<IfModule mod_filter.c>` & `</IfModule>`
# lines as `AddOutputFilterByType` is still in the core directives.

<IfModule mod_filter.c>
AddOutputFilterByType DEFLATE application/atom+xml \
application/javascript \
Expand Down
16 changes: 14 additions & 2 deletions test/fixtures/content/.htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ ErrorDocument 404 /404.html
# Web fonts
AddType application/font-woff woff
AddType application/vnd.ms-fontobject eot

AddType application/x-font-ttf ttc ttf
AddType font/opentype otf

AddType image/svg+xml svg svgz
AddEncoding gzip svgz

# Other
AddType application/octet-stream safariextz
Expand Down Expand Up @@ -294,14 +294,26 @@ AddDefaultCharset utf-8
<IfModule mod_deflate.c>

# Force compression for mangled headers.

<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
</IfModule>
</IfModule>

# Compress all output labeled with one of the following media types
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

# Mark certain resources as been compressed.

<IfModule mod_mime.c>
AddEncoding gzip svgz
</IfModule>

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

# Compress all output labeled with one of the following media types.

<IfModule mod_filter.c>
AddOutputFilterByType DEFLATE application/atom+xml \
application/javascript \
Expand Down
Binary file modified test/fixtures/content/test.svgz
Binary file not shown.

0 comments on commit 73a107e

Please sign in to comment.