Author Topic: How to do so all servers have gzip compression?  (Read 365 times)

0 Members and 1 Guest are viewing this topic.

Offline
*
How to do so all servers have gzip compression?
« on: November 06, 2017, 05:30:19 PM »
How to do so all servers have gzip compression?
centos 6 64x
cwp 6
Apache/2.4.29 (Unix)

Offline
***
Re: How to do so all servers have gzip compression?
« Reply #1 on: November 07, 2017, 07:15:58 AM »
Check this tutorial to enable gzip compression on your server:- http://idroot.net/tutorials/how-to-enable-gzip-compression-on-apache/
https://www.24x7servermanagement.com/
Server Management, Server Security, Server Monitoring.
India's Leading Managed Service Provider !!

Offline
***
Re: How to do so all servers have gzip compression?
« Reply #2 on: January 12, 2018, 04:05:29 AM »
add these lines to your httpd.conf
/usr/local/apache/conf/httpd.conf


Quote
LoadModule deflate_module modules/mod_deflate.so

#set compression level
DeflateCompressionLevel 9
<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/html
  AddOutputFilterByType DEFLATE text/css
  AddOutputFilterByType DEFLATE text/javascript
  AddOutputFilterByType DEFLATE text/xml
  AddOutputFilterByType DEFLATE text/plain
  AddOutputFilterByType DEFLATE image/x-icon
  AddOutputFilterByType DEFLATE image/svg+xml
  AddOutputFilterByType DEFLATE application/rss+xml
  AddOutputFilterByType DEFLATE application/javascript
  AddOutputFilterByType DEFLATE application/x-javascript
  AddOutputFilterByType DEFLATE application/xml
  AddOutputFilterByType DEFLATE application/xhtml+xml
  AddOutputFilterByType DEFLATE application/x-font
  AddOutputFilterByType DEFLATE application/x-font-truetype
  AddOutputFilterByType DEFLATE application/x-font-ttf
  AddOutputFilterByType DEFLATE application/x-font-otf
  AddOutputFilterByType DEFLATE application/x-font-opentype
  AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
  AddOutputFilterByType DEFLATE font/ttf
  AddOutputFilterByType DEFLATE font/otf
  AddOutputFilterByType DEFLATE font/opentype

# For Olders Browsers Which Can't Handle Compression
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4\.0[678] no-gzip
  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>

# Cache 480 weeks
    <FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf|mp4|mp3|eot|woff|ttf|svg|iefix)$">
    Header set Cache-Control "max-age=290304000, public"
    </FilesMatch>

<IfModule mod_expires.c>
# Enable expirations
ExpiresActive On
# Default directive
ExpiresDefault "access plus 1 month"
# My favicon
ExpiresByType image/x-icon "access plus 1 year"
# Media: images, video, audio
  ExpiresByType image/gif                 "access plus 1 year"
  ExpiresByType image/png                 "access plus 1 year"
  ExpiresByType image/jpg                 "access plus 1 year"
  ExpiresByType image/jpeg                "access plus 1 year"
  ExpiresByType video/ogg                 "access plus 1 year"
  ExpiresByType audio/ogg                 "access plus 1 year"
  ExpiresByType video/mp4                 "access plus 1 year"
  ExpiresByType video/webm                "access plus 1 year"
# Webfonts
  ExpiresByType font/truetype             "access plus 1 year"
  ExpiresByType font/opentype             "access plus 1 year"
  ExpiresByType application/x-font-woff   "access plus 1 year"
  ExpiresByType image/svg+xml             "access plus 1 year"
  ExpiresByType application/vnd.ms-fontobject "access plus 1 year"
# CSS and JavaScript
  ExpiresByType text/css                  "access plus 1 year"
  ExpiresByType application/javascript    "access plus 1 year"
  ExpiresByType text/javascript           "access plus 1 year"
</IfModule>
<IfModule mod_headers.c>
    Header append Cache-Control "public"
</IfModule>

# Disable Folder Files Listing
Options -Indexes
#Prevent acess to php.ini
<FilesMatch "^php5?\.(ini|cgi)$">
Order Deny,Allow
Deny from All
Allow from env=REDIRECT_STATUS
</FilesMatch>

explanation:
- mod_deflate.so is disabled by default, you should enable it
- all media files(images, css, js...) will be cached and have a long expiration. no worry, this is based on last modified date of a file and if you replace those images on server, new file will be loaded on client.
« Last Edit: January 12, 2018, 04:10:56 AM by locvfx »