CSS and JS gZip is not working

I have enabled gZip compression but it says HTML gZip is enabled not for CSS and JS. I am on apache server and this is my htaccess: https://pastebin.com/zPt4eBMa

  • Adam Czajczyk

    Hello Rob

    I hope you're well today!

    I have checked your site and I think the issue here is a bit different than .htaccess and Hummingbird's settings.

    Some "compression checks" sites indeed return an information that the site is compress but that's a homepage HTML compression check and that one is working. Hummingbird reports no compression for CSS and JS and PageSpeed Insights check confirms that.

    The WPMU DEV Dashboard plugin and Hummingbird they both detect Apache as a webserver and the fact that you actually do have and use .htaccess file confirms that too. However, when requesting the site from outside, the response indicates that the webserver is nginx.

    That usually means that the "real configuration" of a server is an Apache serving your website with Nginx "in front" serving as (that depends on the host) a sort of load balancer/reverse proxy/caching server.

    So, it's a webserver behind webserver (kind of "stack"). In such cases it's often Nginx that has to be configured instead of Apache because even if Apache compresses the data, it's only for a route from Apache to Nginx and then from Nginx to the end user the data travels as served by Nginx "rules".

    I'm not sure whether you are using a shared hosting account or some VPS/dedicated server and what kind of configuration are you able to access to but if you do have an option to change Nginx configuration:

    - please go to the "Hummingbird -> Gzip Compression" page and from the server list at the bottom select "NGINX",
    - follow guide there to add required rules to Nginx configuration.

    If you're not allowed to change Nginx configuration or you don't know how to access it, please get in touch with your host and ask them if they can confirm such setup (nginx in front of apache) adn if so:

    - what are the Gzip compression rules currently applied to Nginx
    - if they confirm it's not set to compress JS/CSS, ask them if they could change that configuration for you.

    That should help with the issue.

    Kind regards,

  • Rob

    Hi Jaxom and Adam

    Many thanks for both your replies!

    Turned out I had two htaccess files which obviously didn't help, but thanks Jaxom for your input there.

    Adam was correct with the Nginx settings. I had to re-do all the settings and have now got a full rack of green messages in my dashboard! So many thanks for that.

    I now intend to (very slowly) start adding js and css scripts for minification, and literally do one every few days rather than what I did yesterday, which was do them all in one go and smash the site!

    Cheers, guys.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.