Site5 - Built For Designers & Developers MENU
Home  ›  Control Panels  ›  cPanel: Optimize Your Website using cPanel

cPanel: Optimize Your Website using cPanel

16 Comments

In this article, we will show you how to enable website compression using the mod_deflate function on our server automatically compress specified types of content when visitors access that content.


Configuring Optimization via .htaccess

For this demonstration, you will need basic knowledge of htaccess files and how to create/edit them.

1) Login to your account using either (s)FTP, SSH, or the File Manager

2) Create or edit the htaccess file inside of your web root (public_html).

3) Add all or part of the following depending on what filetypes you wish to compress.

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/x-javascript

4) Save the changes.

For more advanced information regarding deflate, please click here.

Still have a question? Or need help?
See an error in this article or want to suggest a missing topic? Please leave us a comment below! If you need technical support with your account, please email us, chat live with a representative, or call us!

16 Comments

  • Just guessing, but should it say “application/x-javascript” in the last line? :)

    • Hello Malte,

      I hope this comment finds you well!

      Thank you for pointing that mistake out! I have corrected the article. :)

      I hope you have a great day! :)

  • When updating the .htaccess file does this take time to propagate the changes? I’ve updated the file, but PageSpeed is still suggesting that I enable compression. Thanks

    • Nevermind, I needed to place the .htaccess file within the directory that redirected to the root URL.

  • Hi there,
    I have added the following to my .htaccess,
    However it does not seam to work.
    Could you give me a hand please?

    With regards,
    Nalesso Antonio

    • Hi Antonio,

      Very strange, as that should work normally. I would recommend opening a support ticket with the error you are seeing, and our senior technicians can certainly take a look at it.

  • Hi There

    Just would like to confirm does this work for images?

    Thx

    • Hi Clayton,

      It should, yes. Some examples would be as follows:

      AddOutputFilterByType DEFLATE image/svg+xml
      AddOutputFilterByType DEFLATE image/x-icon

      • Thanks to try it out

      • I’m just curious about how this works: what’s the difference between ‘text/xml’ and image/svg+xml? Isn’t an image with .svg suffix treated as an xml text file?

        • Hello Peter,

          Essentially, yes

          • Thanks James. So would

            AddOutputFilterByType DEFLATE text/xml

            ensure that svg images are compressed when served?

            • Hello Peter,

              It may, but there should be no harm in also adding:

              AddOutputFilterByType DEFLATE image/svg+xml

  • Worked like a dream.

    And as its a multisite, only had to add it to the root htacccess file for it to work for all the other sites, as proved on http://developers.google.com/speed/pagespeed/insights

    Fab.

  • This worked for me. I have a question though, I just read an article (http://www.giftofspeed.com/enable-gzip-compression/ ) which stated that you can also use mod_gzip instead of mod_deflate. Which one do you guys recommend and are there any studies done which of the two has the better compression?

    • Hello Marlin,

      Both will work fine, and it really is up to your personal preference. As for which has better compression, that depends on what you’re compressing :) Honestly, your best bet is to try one, then the other, and decide which works best for you.

Money Back Guarantees
Click to verify BBB accreditation and to see a BBB report.