Results 1 to 17 of 17
  1. #1

    GZIP Compression

    Is it a good thing to add mod_deflate and enable gzip compression for websites?

    How well does it work? Does it work better for certain websites than others? Does it break things or cause other problems?

  2. #2
    Join Date
    May 2013
    Location
    USA
    Posts
    928
    It can certainly help reduce page load time for your users, but remember there are overheard costs associated with compressing the files so if you're already running a high CPU load on your server then you probably won't want to enable gzip. Try it out during non-peak traffic hours and monitor how server load responds.

    We often enable gzip for .htm, .html, .php, .js, .css extensions.
    ▄▀▄ Brian Harrison, Lead Engineer - Reprise Hosting (AS62838)
    ▄▀▄ Deals on cheap dedicated server hosting. IPMI included! Unmetered bandwidth.
    ▄▀▄ Website migration, 24/7/365 support, basic server setup, 15 day money back.
    ▄▀▄ Looking for DEALS on self-managed cheap VPS hosting? Visit VPSHostingDEAL.com

  3. #3
    you should use it

  4. #4
    to effect GZIP Compression is very helpful when we open the site pages and better combine well with gzip for. htm,. html,. php,. js,. css extensions as described by @BrianHarrison

  5. #5
    Join Date
    Jun 2003
    Location
    World Wide Web
    Posts
    581
    Mod_deflate is an apache module that can be used to compress data using gzip compression before sending it to the user. For bandwidth intensive websites, using this feature can offer a benefit, as the server is compressing data before sending it you will be using less bandwidth. The major drawback to using mod_deflate however is that the server may need to use more resources to compress each file and this in turn can cause performance issues on older servers.
    SupportExpertz.com - the name says it all!
    Managed Cloud Servers
    Server Management and Monitoring
    24x7 outsourced customer support

  6. #6
    Join Date
    Mar 2013
    Location
    North and South America
    Posts
    166
    From a customer's standpoint it is great. All modern browsers support it. If you are setting it up with cPanel or properly yourself it will fallback to uncompressed if anyone doesn't have a modern browser made in the last decade.

    Sure it takes a but of overhead, but so does a soft firewall. And customers are increasingly asking for this and it is a strong selling point.

    We compress the following MIME types: application/atom_xml application/atom+xml application/javascript application/json application/rss+xml application/vnd.ms-fontobject application/x-font-ttf application/x-httpd-eruby application/x-httpd-fastphp application/x-httpd-php application/x-javascript application/xhtml+xml application/xml image/svg+xml image/x-icon font/opentype text/css text/html text/javascript text/js text plain text/x-component text/xml
    In addition to GZIP Compression there is browser cache. Working with customers you can do something like:
    in .htaccess or in apache:
    ### BELOW Cache for 1 year
    <FilesMatch "\.(ico|pdf|jpg|jpeg|png|gif|html|htm|xml|swf)$">
    Header set Cache-Control "max-age=31536050"
    </FilesMatch>

    ### BELOW Cache for 30 days
    <FilesMatch "\.(txt|xsl|js|css)$">
    Header set Cache-Control "max-age=2592000"
    </FilesMatch>
    Of course change the settings based on needs. This dictates to many browsers how long to cache files on the client device. This is a big saver of bandwidth and again a good service to make sites load faster.

  7. #7
    Join Date
    Mar 2013
    Location
    North and South America
    Posts
    166
    Quote Originally Posted by turbowarp View Post
    Is it a good thing to add mod_deflate and enable gzip compression for websites?

    How well does it work? Does it work better for certain websites than others? Does it break things or cause other problems?
    Sorry sometimes I forget to answer the question fully and I do apologize!

    Others explained how it works, but it simply compresses the file prior to sending (using GZIP) and then the browser simply decompresses it. It sounds complicated and even maybe not efficient. But it actually ends up causing the page to load faster. Why? Because the weak link is in that long network pipe. Compression and deflating is done easily (on modern servers and computers). So the time saved to send the compressed resource certainly makes up for any time to zip and unzip.

    I will say it isn't wise to compress images, audio and video this way. Those types of resources are best compressed via other means. Namely, when created or as a batch job once on a stack or files. Otherwise, most media types are already compressed and if you specify them to GZIP then you are waisting server resources to get unlikely benefit. So the compression of text it what is normally done. So sites with text files that you specify will benefit to the degree they have that resource. Try a website speed tool like: http://tools.pingdom.com/fpt/
    (just an example, pick any one) and try your sites with GZIP and without (turn it on and off). See how well it impacts. I've never seen negative impact, but anything is possible.

    Seriously, on thousands of sites we have no issues with it, when properly configured. So I'd say issues are not really a factor. Sure there may be one and you can turn it off for that client (or yourself).

    I will add that it does improve SEO page ranking. Another selling benefit! Google and other providers love it. I think it saves them money!
    Last edited by gPowerHost; 10-27-2013 at 10:56 AM. Reason: typos!

  8. #8
    I will turn it on and watch my resources and adjust the compression level accordingly. Thanks all for your posts.

  9. #9
    I have cPanel version 11.38x ... it offers pigz, does pigz replace gzip?

  10. #10
    Join Date
    Mar 2013
    Location
    North and South America
    Posts
    166
    Quote Originally Posted by turbowarp View Post
    I have cPanel version 11.38x ... it offers pigz, does pigz replace gzip?
    Yes. It is a version that works on modern, parallel, multi-processor servers. So you are good with that.

  11. #11
    It is a good idea to enable gzip compression for static contents like css, js, images, html etc.
    || Web Hosting Blog - Web Hosting security & latest web hosting industry Announcements
    || Web Hosting Discussion - A Web Hosting community

  12. #12
    I have enabled gzip. I found this tool to test gzip compression:
    HTTP Compression Test

    On this VPS I have 2 cPanel accounts. On one of the cPanel accounts, I can set "Website Optimization" to compress and it stays enabled.

    On the other cPanel account, same VPS, Website Optimization will not stay enabled. What's the problem?

  13. #13
    Join Date
    Mar 2013
    Location
    North and South America
    Posts
    166
    By not staying enabled are you talking about in cPanel when you try and set it up? Because out of the box this should work without modification in cPanel, except setting up Apache's mod_deflate. We do it many times a day: cpanel->Software/services->Optimize Website->select: Compress the specified MIME types-> Paste in your MIME types like:
    application/atom_xml application/atom+xml application/javascript application/json application/rss+xml application/vnd.ms-fontobject application/x-font-ttf application/x-httpd-eruby application/x-httpd-fastphp application/x-httpd-php application/x-javascript application/xhtml+xml application/xml image/svg+xml image/x-icon font/opentype text/css text/html text/javascript text/js text plain text/x-component text/xml
    ->click Update Settings and it should report back "Website optimization preferences updated."

    Do you get an error anywhere? Sorry if I oversimplified things, but can you expand on how you determine it is not staying enabled?

  14. #14
    Quote Originally Posted by gPowerHost View Post
    By not staying enabled are you talking about in cPanel when you try and set it up? Because out of the box this should work without modification in cPanel, except setting up Apache's mod_deflate. We do it many times a day: cpanel->Software/services->Optimize Website->select: Compress the specified MIME types-> Paste in your MIME types like:

    ->click Update Settings and it should report back "Website optimization preferences updated."

    Do you get an error anywhere? Sorry if I oversimplified things, but can you expand on how you determine it is not staying enabled?
    No, I don't get any errors, when I select the "Specified MIme Types" and click "Update Settings" I get this:
    Optimize Website
    Website optimization preferences updated.

    Content compression: Enabled for text/html text/plain text/xml
    But, when I go back to look, the radio button is back on "Disabled". But, on the other cPanel account (same vps) it stays enabled.

  15. #15
    Join Date
    Mar 2013
    Location
    North and South America
    Posts
    166
    OK. Obviously the accounts are one the same box right? Are they separate users?

    And you verified that it is both not enabled and the test site is also verifying this?

    My theory is that it is possible for easy apache to have error (failing the dry run?) upon compilation and maybe mod_deflate was not enabled for that user. Try to rebuild apache and watch the output.

  16. #16
    Join Date
    Mar 2013
    Location
    North and South America
    Posts
    166
    Also check the .htaccess, php.ini and httpd.conf (don't edit that file) file on that account and see that some script (or someone) didn't add some code to disable mod_deflate. Report back anything like: <IfModule mod_deflate.c>...

  17. #17
    Join Date
    Mar 2013
    Location
    North and South America
    Posts
    166
    One more thing. Apparently cpanel adds or modifies an .htaccess file in your home directory. I'm not talking about the one that might be in /public_html/. Check out that file, and the permissions. Maybe the permissions are too tight. While locking down an .htaccess as tight as 404 will work, it will prevent cpanel from modifying it. So you can either change the permissions to say, 604, either temporarily (while you enable the feature in cpanel) or permanently, if your security policy is accordingly. Note: I can't tell you what permissions you should run on your server. But I usually never recommend anything looser than 604 for .htaccess

    If cpanel wrote to home/user_account/.htaccess it might look somerthing like this:
    <IfModule mod_deflate.c>
    AddOutPutFilterByType DEFLATE application/atom_xml application/atom+xml application/javascript application/json application/rss+xml application/vnd.ms-fontobject application/x-font-ttf application/x-httpd-eruby application/x-httpd-fastphp application/x-httpd-php application/x-javascript application/xhtml+xml application/xml image/svg+xml image/x-icon font/opentype text/css text/html text/javascript text/js text plain text/x-component text/xml
    <IfModule mod_setenvif.c>
    # Netscape 4.x has some problems...
    BrowserMatch ^Mozilla/4 gzip-only-text/html

    # Netscape 4.06-4.08 have some more problems
    BrowserMatch ^Mozilla/4\.0[678] no-gzip

    # MSIE masquerades as Netscape, but it is fine
    # BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

    # NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
    # the above regex won't work. You can use the following
    # workaround to get the desired effect:
    BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

    # Don't compress images
    SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary
    </IfModule>

    <IfModule mod_headers.c>
    # Make sure proxies don't deliver the wrong content
    Header append Vary User-Agent env=!dont-vary
    </IfModule>
    </IfModule>

Similar Threads

  1. Enable gzip compression
    By ddrhost in forum Web Hosting
    Replies: 10
    Last Post: 02-28-2012, 09:24 AM
  2. Testing GZIP compression and speed of a website
    By jq3385 in forum Web Hosting
    Replies: 4
    Last Post: 06-21-2011, 10:19 AM
  3. How to enable Gzip Compression?
    By jani in forum Web Design and Content
    Replies: 5
    Last Post: 08-10-2010, 12:28 PM
  4. Help Please :: Can't do gzip compression via .htaccess
    By SWDevil in forum Hosting Security and Technology
    Replies: 4
    Last Post: 08-12-2009, 02:27 AM
  5. http compression with gzip
    By section31 in forum Programming Discussion
    Replies: 4
    Last Post: 10-05-2004, 10:35 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •