hoangweb
4/29/2016 - 7:53 AM

.htaccess - gzip-compression

.htaccess - gzip-compression

# ----------------------------------------------------------------------
# Gzip compression
# ----------------------------------------------------------------------
<IfModule mod_deflate.c>
# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/xjavascript
AddType x-font/otf .otf
AddType x-font/ttf .ttf
AddType x-font/eot .eot
AddType x-font/woff .woff
AddType image/x-icon .ico
AddType image/png .png
</IfModule>
<IfModule mod_expires.c>
  ExpiresActive on
  ExpiresByType image/gif "access plus 1 month"
  ExpiresByType image/jpeg "access plus 1 month"
  ExpiresByType image/png "access plus 1 month"
  ExpiresByType text/css "access plus 1 month"
  ExpiresByType application/javascript "access plus 1 month"
  ExpiresByType application/x-javascript "access plus 1 month"
</IfModule>

# 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>
#Compression: http://code.google.com/speed/page-speed/docs/payload.html#GzipCompression
<IfModule mod_deflate.c>
  AddOutputFilter DEFLATE application/atom+xml
  AddOutputFilter DEFLATE application/json
  AddOutputFilter DEFLATE application/xhtml+xml
  AddOutputFilter DEFLATE application/xml
  AddOutputFilter DEFLATE text/css
  AddOutputFilter DEFLATE text/html
  AddOutputFilter DEFLATE text/plain
  AddOutputFilter DEFLATE text/x-component
  AddOutputFilter DEFLATE text/xml

  AddOutputFilterByType DEFLATE text/html
  AddOutputFilterByType DEFLATE text/xml
  AddOutputFilterByType DEFLATE text/css
  AddOutputFilterByType DEFLATE application/xml
  AddOutputFilterByType DEFLATE application/xhtml+xml
  AddOutputFilterByType DEFLATE application/rss+xml
  AddOutputFilterByType DEFLATE application/javascript
  AddOutputFilterByType DEFLATE application/x-javascript


  # The following MIME types are in the process of registration
  AddOutputFilter DEFLATE application/xslt+xml
  AddOutputFilter DEFLATE image/svg+xml

  # The following MIME types are NOT registered
  AddOutputFilter DEFLATE application/mathml+xml
  AddOutputFilter DEFLATE application/rss+xml

  # JavaScript has various MIME types
  AddOutputFilter DEFLATE application/javascript
  AddOutputFilter DEFLATE application/x-javascript
  AddOutputFilter DEFLATE text/ecmascript
  AddOutputFilter DEFLATE text/javascript

  # .ico files and other compressible images
  AddOutputFilter DEFLATE image/vnd.microsoft.icon
  AddOutputFilter DEFLATE image/x-icon
  AddOutputFilter DEFLATE image/bmp
  AddOutputFilter DEFLATE image/tiff
  AddOutputFilter DEFLATE application/pdf

  # compressible fonts (.woff is already compressed)
  AddOutputFilter DEFLATE font/opentype
  AddOutputFilter DEFLATE application/x-font-ttf
  AddOutputFilter DEFLATE application/vnd.ms-fontobject
</IfModule>