Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

More general compression configuration for Apache #1173

Closed
wants to merge 1 commit into from

2 participants

@alrra
Owner
1) Related discussion: #1012
2) About the solution:
  • Works with Apache ≥ 2.1 and requires mod_deflate and mod_filter to be enabled.
    (personally, I don't think we should target lower as Apache < 2.2 is no longer recommended)
  • For Apache ≥ 2.1 → 2.3.7, mod_filter isn't needed, but I think requiring it and using this solution is the best way going forward (plus, it doesn't introduce other dependencies to other modules like, for example, mod_version)
3) Other information:
  • Apache ≥ 2.3.7:

    • AddOutputFilterByType was moved into mod_filter, so the <IfModule mod_filter.c> condition has to be present and / or mod_filter has to be enabled.
    • Best solution:

      <IfModule mod_deflate.c>
           # ...
           <IfModule mod_filter.c>
               AddOutputFilterByType DEFLATE application/atom+xml ...
           </IfModule>
      </IfModule>
      
  • Apache ≥ 2.1 → 2.3.7:

    • AddOutputFilterByType works without mod_filter, so there is no need to enable it or to have the <IfModule mod_filter.c> condition.
    • Best solution:

        <IfModule mod_deflate.c>
              # ...
              AddOutputFilterByType DEFLATE application/atom+xml ...
        </IfModule>
      
  • Apache 2.0.33 → 2.1

@necolas necolas referenced this pull request from a commit
@alrra alrra More general compression configuration for Apache
Works with Apache ≥ 2.1 and requires `mod_deflate` and `mod_filter` to
be enabled. However, use of Apache < 2.2 is no longer recommended.

For Apache ≥ 2.1 → 2.3.7, `mod_filter` isn't needed, but requiring it
and using this solution is the best way going forward (plus, it doesn't
introduce other dependencies to other modules like, for example,
`mod_version`).

Fix gh-1012
Ref gh-1173
a36b296
@necolas
Owner

Thanks! Merged.

@necolas necolas closed this
@necolas necolas referenced this pull request from a commit in h5bp/server-configs
@alrra alrra More general compression configuration for Apache
Works with Apache ≥ 2.1 and requires `mod_deflate` and `mod_filter` to
be enabled. However, use of Apache < 2.2 is no longer recommended.

For Apache ≥ 2.1 → 2.3.7, `mod_filter` isn't needed, but requiring it
and using this solution is the best way going forward (plus, it doesn't
introduce other dependencies to other modules like, for example,
`mod_version`).

Fix h5bp/html5-boilerplate#1012
Ref h5bp/html5-boilerplate#1173
1ec4456
@alrra alrra referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@alrra alrra referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@alrra alrra referenced this pull request from a commit in h5bp/server-configs-apache
@alrra alrra More general compression configuration for Apache
Works with Apache ≥ 2.1 and requires `mod_deflate` and `mod_filter` to
be enabled. However, use of Apache < 2.2 is no longer recommended.

For Apache ≥ 2.1 → 2.3.7, `mod_filter` isn't needed, but requiring it
and using this solution is the best way going forward (plus, it doesn't
introduce other dependencies to other modules like, for example,
`mod_version`).

Fix  h5bp/html5-boilerplate#1012
Ref  h5bp/html5-boilerplate#1173
957e060
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 18 additions and 30 deletions.
  1. +18 −30 .htaccess
View
48 .htaccess
@@ -163,36 +163,24 @@ AddType text/vtt vtt
</IfModule>
</IfModule>
- # HTML, TXT, CSS, JavaScript, JSON, XML, HTC:
- <IfModule filter_module>
- FilterDeclare COMPRESS
- FilterProvider COMPRESS DEFLATE resp=Content-Type $text/html
- FilterProvider COMPRESS DEFLATE resp=Content-Type $text/css
- FilterProvider COMPRESS DEFLATE resp=Content-Type $text/plain
- FilterProvider COMPRESS DEFLATE resp=Content-Type $text/xml
- FilterProvider COMPRESS DEFLATE resp=Content-Type $text/x-component
- FilterProvider COMPRESS DEFLATE resp=Content-Type $application/javascript
- FilterProvider COMPRESS DEFLATE resp=Content-Type $application/json
- FilterProvider COMPRESS DEFLATE resp=Content-Type $application/xml
- FilterProvider COMPRESS DEFLATE resp=Content-Type $application/xhtml+xml
- FilterProvider COMPRESS DEFLATE resp=Content-Type $application/rss+xml
- FilterProvider COMPRESS DEFLATE resp=Content-Type $application/atom+xml
- FilterProvider COMPRESS DEFLATE resp=Content-Type $application/vnd.ms-fontobject
- FilterProvider COMPRESS DEFLATE resp=Content-Type $image/svg+xml
- FilterProvider COMPRESS DEFLATE resp=Content-Type $image/x-icon
- FilterProvider COMPRESS DEFLATE resp=Content-Type $application/x-font-ttf
- FilterProvider COMPRESS DEFLATE resp=Content-Type $font/opentype
- FilterChain COMPRESS
- FilterProtocol COMPRESS DEFLATE change=yes;byteranges=no
- </IfModule>
-
- <IfModule !mod_filter.c>
- # Legacy versions of Apache
- AddOutputFilterByType DEFLATE text/html text/plain text/css application/json
- AddOutputFilterByType DEFLATE application/javascript
- AddOutputFilterByType DEFLATE text/xml application/xml text/x-component
- AddOutputFilterByType DEFLATE application/xhtml+xml application/rss+xml application/atom+xml
- AddOutputFilterByType DEFLATE image/x-icon image/svg+xml application/vnd.ms-fontobject application/x-font-ttf font/opentype
+ # Compress all output labeled with one of the following MIME-types
+ <IfModule mod_filter.c>
+ AddOutputFilterByType DEFLATE application/atom+xml \
+ application/javascript \
+ application/json \
+ application/rss+xml \
+ application/vnd.ms-fontobject \
+ application/x-font-ttf \
+ application/xhtml+xml \
+ application/xml \
+ font/opentype \
+ image/svg+xml \
+ image/x-icon \
+ text/css \
+ text/html \
+ text/plain \
+ text/x-component \
+ text/xml
</IfModule>
</IfModule>
Something went wrong with that request. Please try again.