Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

cheah2go's avatar

enabling gzip with nginx and verifying that it's working

How do I check if my nginx config is actually compressing assets? I have the following in my nginx.conf:

    gzip on;
    
    gzip_disable "msie6";

    gzip_vary on;
    gzip_proxied any;
    gzip_comp_level 6;
    gzip_buffers 16 8k;
    gzip_http_version 1.1;
    gzip_types 
        text/plain 
        text/css 
        application/json 
        application/x-javascript 
        text/xml 
        application/xml 
        application/xml+rss 
        text/javascript;

But Google page speed insights keeps telling me that I still need to compress .js and .svg files...?

0 likes
5 replies
cheah2go's avatar

I found that including the following in gzip_types solved it:

application/javascript image/svg+xml

bashy's avatar

Remember to not use it if your site is HTTPS :) (or know how to avoid common flaws with BREACH / CRIME).

cheah2go's avatar

@bashy, thanks for the tip. I don't want to be penalized by Google for not compressing, so do you have any resources you can recommend to teach me how to protect against these attacks?

Please or to participate in this conversation.