Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Enabling gzip by default questions

Discussion in 'Workarounds and Optimization' started by Gojko, May 10, 2019.

  1. Gojko

    Gojko Well-Known Member

    Joined:
    Nov 24, 2014
    Messages:
    94
    Likes Received:
    7
    Trophy Points:
    8
    Location:
    Macedonia
    cPanel Access Level:
    Root Administrator
    Hello i'm thinking about optimize by default with config file of apache.

    something like Enable gzip compression | GTmetrix

    (and other like headers etc.) put in apache config file so clients don't need to put it in theirs .htaccess file

    so my question is: is this possible?
    what if i put that code, and someone don't want to have it. Can he disable this via .htaccess and how (with gzip example)?

    and one more if i put example gzip compression and someone also put the same thing in his .htaccess what would happen?
     
  2. dalem

    dalem Well-Known Member PartnerNOC

    Joined:
    Oct 24, 2003
    Messages:
    2,908
    Likes Received:
    127
    Trophy Points:
    368
    Location:
    SLC
    cPanel Access Level:
    DataCenter Provider
    Add the code of your link to the Pre Main Include of your Apache include editor
    and all sites will be gziped/mod_deflated :)
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. Gojko

    Gojko Well-Known Member

    Joined:
    Nov 24, 2014
    Messages:
    94
    Likes Received:
    7
    Trophy Points:
    8
    Location:
    Macedonia
    cPanel Access Level:
    Root Administrator
    I know that, but I am worried about other things that I have already mentioned.

    Like this if i put in conf file of apache
    Code:
    <IfModule mod_expires.c>
      FileETag MTime Size
      AddOutputFilterByType DEFLATE text/plain text/html text/xml text/css application/xml application/xhtml+xml application/rss+xml application/javascript application/x-javascript
      ExpiresActive On
      ExpiresByType text/html "access 600 seconds"
      ExpiresByType application/xhtml+xml "access 600 seconds"
      ExpiresByType text/css "access 1 month"
      ExpiresByType text/javascript "access 1 month"
      ExpiresByType text/x-javascript "access 1 month"
      ExpiresByType application/javascript "access 1 month"
      ExpiresByType application/x-javascript "access 1 month"
      ExpiresByType application/x-shockwave-flash "access 1 month"
      ExpiresByType application/pdf "access 1 month"
      ExpiresByType image/x-icon "access 1 year"
      ExpiresByType image/jpg "access 1 year" 
      ExpiresByType image/jpeg "access 1 year"
      ExpiresByType image/png "access 1 year"
      ExpiresByType image/gif "access 1 year"
      ExpiresDefault "access 1 month"
    </IfModule>
    what if someone want to turn this off or want to change "access 1 month" to "access 1 year"?
     
    #3 Gojko, May 12, 2019
    Last edited: May 12, 2019
  4. cPanelMichael

    cPanelMichael Technical Support Community Manager Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    47,272
    Likes Received:
    2,154
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello @Gojko,

    You may want to consider simply enabling the Optimize Website feature at account creation time and then automatically appending your custom configuration rules to the /home/$username/.htaccess file at account creation time via a post account creation hook. The following resources are useful as proof-of-concepts if you want more information about how hooks work and how to automate tasks:

    Tutorial - How to Setup Standardized Hooks with BASH in cPanel & WHM
    Tutorial - How To Automatically Install WordPress On New Accounts

    Your users could then disable the Optimize Website feature or manually modify their .htaccess files in order to customize the rules.

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice