Answers.Body: <p>Apache supports gzip with two compression modules: <code>mod_gzip</code> and <code>mod_deflate</code>. The latter is supposedly more widely available but some hosts may have one or the other.</p>
  
  <p><code>mod_gzip</code> is the older of the modules and came with Apache 1.3, <code>mod_deflate</code> is newer and compresses better, though when you're dealing with text like js/css/html, the difference is only a few bytes.</p>
  
  <p>If <code>mod_deflate</code> is giving you fits, you could also try <code>mod_gzip</code> instead.</p>
  
  <pre><code>&lt;ifModule mod_gzip.c&gt;
    mod_gzip_on Yes
    mod_gzip_dechunk Yes
    mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
    mod_gzip_item_include mime ^application/x-javascript.*
    mod_gzip_item_include mime ^text/.*
    mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
    mod_gzip_item_exclude mime ^image/.*  
    mod_gzip_item_include handler ^cgi-script$
  &lt;/ifModule&gt;
  </code></pre>
  
  <p>If Apache is running PHP as mod_php, you can also see what modules are running using something like:</p>
  
  <pre><code>&lt;?php
      print_r( apache_get_modules() );
  ?&gt;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-16T23:16:01.773Z
Answers.Text: Thanks! I will try check this. But as per the documentation, mod_deflate should be installed (and mod_gzip not), and gzip DOES work for my HTML files.
Answers.UserDisplayName: KSP
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-16T20:12:04.373Z
Answers.LastActivityDate: 2017-08-16T20:12:04.373Z
Answers.UserDisplayName: RitterKnight
Answers.Body: <p>You can use .htaccess config from <a href="https://github.com/h5bp/html5-boilerplate/blob/master/dist/.htaccess" rel="nofollow noreferrer">HTML Boilerplate</a> for better configuration. There are a lot of useful config option there.</p>
  
  <p>I use this config to enable gzip compression in my personal blog, and it's worked perfectly.</p>
  
  <pre><code>&lt;IfModule mod_deflate.c&gt;
  
      # Force compression for mangled `Accept-Encoding` request headers
      &lt;IfModule mod_setenvif.c&gt;
          &lt;IfModule mod_headers.c&gt;
              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
          &lt;/IfModule&gt;
      &lt;/IfModule&gt;
  
  
      # Compress all output labeled with one of the following media types.
      &lt;IfModule mod_filter.c&gt;
          AddOutputFilterByType DEFLATE "application/atom+xml" \
                                        "application/javascript" \
                                        "application/json" \
                                        "application/ld+json" \
                                        "application/manifest+json" \
                                        "application/rdf+xml" \
                                        "application/rss+xml" \
                                        "application/schema+json" \
                                        "application/vnd.geo+json" \
                                        "application/vnd.ms-fontobject" \
                                        "application/x-font-ttf" \
                                        "application/x-javascript" \
                                        "application/x-web-app-manifest+json" \
                                        "application/xhtml+xml" \
                                        "application/xml" \
                                        "font/eot" \
                                        "font/opentype" \
                                        "image/bmp" \
                                        "image/svg+xml" \
                                        "image/vnd.microsoft.icon" \
                                        "image/x-icon" \
                                        "text/cache-manifest" \
                                        "text/css" \
                                        "text/html" \
                                        "text/javascript" \
                                        "text/plain" \
                                        "text/vcard" \
                                        "text/vnd.rim.location.xloc" \
                                        "text/vtt" \
                                        "text/x-component" \
                                        "text/x-cross-domain-policy" \
                                        "text/xml"
  
      &lt;/IfModule&gt;
  
      &lt;IfModule mod_mime.c&gt;
          AddEncoding gzip              svgz
      &lt;/IfModule&gt;
  
  &lt;/IfModule&gt;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-16T23:14:46.047Z
Answers.Text: Thanks! I actually tried using the boilerplate .htaccess, and it still didn't work for some reason … as I'm tiring of 1&1 I'm trying to set up a version now with Digitalocean + Serverpilot, and see if that changes things.
Answers.UserDisplayName: KSP
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-16T18:07:15.727Z
Answers.LastActivityDate: 2017-08-16T18:07:15.727Z
Answers.UserDisplayName: Jefry Dewangga
Body: <p>I'm not 100% sure this is a Craft specific problem, but I'll try here, as it relates to a Craft installation.</p>
  
  <p>After running a number of tests, it seems that my CSS and JavaScript files are not getting GZIP-ed. I have a <code>.htaccess</code> file in my <code>public</code> folder, and no <code>.htaccess</code> files in the subfolders below. My CSS and JS files are stored in <code>/assets/css</code>and <code>/assets/js</code> respectively (relative to the <code>public</code>folder).</p>
  
  <p>My .htaccess file looks like this. Is there something I'm doing wrong? I thought the settings of the <code>.htacces</code> should work for subfolders when not overridden?</p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
      RewriteEngine On
      RewriteBase /
      RewriteOptions InheritDown
  
      # Send would-be 404 requests to Craft
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC]
      RewriteRule (.+) index.php?p=$1 [QSA,L]
  &lt;/IfModule&gt;
  
  &lt;IfModule mod_deflate.c&gt;
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE application/rss+xml
    AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
    AddOutputFilterByType DEFLATE application/x-font
    AddOutputFilterByType DEFLATE application/x-font-opentype
    AddOutputFilterByType DEFLATE application/x-font-otf
    AddOutputFilterByType DEFLATE application/x-font-truetype
    AddOutputFilterByType DEFLATE application/x-font-ttf
    AddOutputFilterByType DEFLATE application/x-javascript
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE font/opentype
    AddOutputFilterByType DEFLATE font/otf
    AddOutputFilterByType DEFLATE font/ttf
    AddOutputFilterByType DEFLATE image/svg+xml
    AddOutputFilterByType DEFLATE image/x-icon
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/javascript
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE text/xml
  &lt;/IfModule&gt;
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-08-15T17:46:59.510Z
Comments.Text: Might be a silly question, but is mod_deflate installed/enabled? You also might have better luck with this one on ServerFault or Stackoverflow.
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-08-15T18:12:10.600Z
Comments.Text: I was thinking the same, but it seems to be installed, and it works for HTML. At the end of the day I think this was the drop to change away from 1&1! :-)
Comments.UserDisplayName: KSP
Tags: <htaccess>
Title: GZIP seems to compress only HTML, not CSS or JavaScript
ThreadText: # GZIP seems to compress only HTML, not CSS or JavaScript
  
  (Asked by: username_0 on 2017-08-14)
  
  I'm not 100% sure this is a Craft specific problem, but I'll try here, as it relates to a Craft installation.
  
  After running a number of tests, it seems that my CSS and JavaScript files are not getting GZIP-ed. I have a `.htaccess` file in my `public` folder, and no `.htaccess` files in the subfolders below. My CSS and JS files are stored in `/assets/css`and `/assets/js` respectively (relative to the `public`folder).
  
  My .htaccess file looks like this. Is there something I'm doing wrong? I thought the settings of the `.htacces` should work for subfolders when not overridden?
  
  ```
  <IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteBase /
      RewriteOptions InheritDown
  
      # Send would-be 404 requests to Craft
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC]
      RewriteRule (.+) index.php?p=$1 [QSA,L]
  </IfModule>
  
  <IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE application/rss+xml
    AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
    AddOutputFilterByType DEFLATE application/x-font
    AddOutputFilterByType DEFLATE application/x-font-opentype
    AddOutputFilterByType DEFLATE application/x-font-otf
    AddOutputFilterByType DEFLATE application/x-font-truetype
    AddOutputFilterByType DEFLATE application/x-font-ttf
    AddOutputFilterByType DEFLATE application/x-javascript
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE font/opentype
    AddOutputFilterByType DEFLATE font/otf
    AddOutputFilterByType DEFLATE font/ttf
    AddOutputFilterByType DEFLATE image/svg+xml
    AddOutputFilterByType DEFLATE image/x-icon
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/javascript
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE text/xml
  </IfModule>
  
  ```
  
  **Tags:** htaccess
  
  > **Comments:**
  > **username_1**: Might be a silly question, but is mod_deflate installed/enabled? You also might have better luck with this one on ServerFault or Stackoverflow.  
  > **username_0**: I was thinking the same, but it seems to be installed, and it works for HTML. At the end of the day I think this was the drop to change away from 1&1! :-)  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2017-08-16. Score: 2
  
  Apache supports gzip with two compression modules: `mod_gzip` and `mod_deflate`. The latter is supposedly more widely available but some hosts may have one or the other.
  
  `mod_gzip` is the older of the modules and came with Apache 1.3, `mod_deflate` is newer and compresses better, though when you're dealing with text like js/css/html, the difference is only a few bytes.
  
  If `mod_deflate` is giving you fits, you could also try `mod_gzip` instead.
  
  ```
  <ifModule mod_gzip.c>
    mod_gzip_on Yes
    mod_gzip_dechunk Yes
    mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
    mod_gzip_item_include mime ^application/x-javascript.*
    mod_gzip_item_include mime ^text/.*
    mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
    mod_gzip_item_exclude mime ^image/.*  
    mod_gzip_item_include handler ^cgi-script$
  </ifModule>
  
  ```
  
  If Apache is running PHP as mod\_php, you can also see what modules are running using something like:
  
  ```
  <?php
      print_r( apache_get_modules() );
  ?>
  
  ```
  
  > **Comments:**
  > **username_0**: Thanks! I will try check this. But as per the documentation, mod_deflate should be installed (and mod_gzip not), and gzip DOES work for my HTML files.  
  
  ---
  
  ### Answer by username_3 on 2017-08-16. Score: 2
  
  You can use .htaccess config from [HTML Boilerplate](https://github.com/h5bp/html5-boilerplate/blob/master/dist/.htaccess) for better configuration. There are a lot of useful config option there.
  
  I use this config to enable gzip compression in my personal blog, and it's worked perfectly.
  
  ```
  <IfModule mod_deflate.c>
  
      # Force compression for mangled `Accept-Encoding` request 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.
      <IfModule mod_filter.c>
          AddOutputFilterByType DEFLATE "application/atom+xml" \
                                        "application/javascript" \
                                        "application/json" \
                                        "application/ld+json" \
                                        "application/manifest+json" \
                                        "application/rdf+xml" \
                                        "application/rss+xml" \
                                        "application/schema+json" \
                                        "application/vnd.geo+json" \
                                        "application/vnd.ms-fontobject" \
                                        "application/x-font-ttf" \
                                        "application/x-javascript" \
                                        "application/x-web-app-manifest+json" \
                                        "application/xhtml+xml" \
                                        "application/xml" \
                                        "font/eot" \
                                        "font/opentype" \
                                        "image/bmp" \
                                        "image/svg+xml" \
                                        "image/vnd.microsoft.icon" \
                                        "image/x-icon" \
                                        "text/cache-manifest" \
                                        "text/css" \
                                        "text/html" \
                                        "text/javascript" \
                                        "text/plain" \
                                        "text/vcard" \
                                        "text/vnd.rim.location.xloc" \
                                        "text/vtt" \
                                        "text/x-component" \
                                        "text/x-cross-domain-policy" \
                                        "text/xml"
  
      </IfModule>
  
      <IfModule mod_mime.c>
          AddEncoding gzip              svgz
      </IfModule>
  
  </IfModule>
  
  ```
  
  > **Comments:**
  > **username_0**: Thanks! I actually tried using the boilerplate .htaccess, and it still didn't work for some reason … as I'm tiring of 1&1 I'm trying to set up a version now with Digitalocean + Serverpilot, and see if that changes things.  
  
  ---
  
  