1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

enable gzip compression in nginx

Discussion in 'Nginx' started by OlgaSeCom, Mar 13, 2015.

?

Are you interested in such kind of post?

  1. Defintly, yes

    2 vote(s)
    100.0%
  2. No

    0 vote(s)
    0.0%
  1. #1
    ==How to enable gzip compression in nginx for static files and speed up your site ==

    to nginx configuration file /etc/nginx/nginx.conf add in "http" directive these lines:

    gzip on;

    gzip_disable "msie6";

    gzip_vary on;

    gzip_proxied any;

    gzip_comp_level 6;

    gzip_buffers 16 8k;

    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss application/javascript text/javascript;


    Save file and restart the nginx:

    /etc/init.d/nginx restart

    After that all the css and javasripts files will be compressed on the server side and your sites will work faster.
     
    OlgaSeCom, Mar 13, 2015 IP
  2. wissam

    wissam Well-Known Member

    Messages:
    2,289
    Likes Received:
    78
    Best Answers:
    1
    Trophy Points:
    185
    #2
    Thank you for the great tutorial, this could be very helpful, I would add an advice of using cloudflare to make the files even more compressed, or by minifiying your files.
     
    wissam, Mar 4, 2016 IP
  3. zuardin

    zuardin Member

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    46
    #3
    this is iam use for my site:
        gzip                on;
        gzip_comp_level     6;
        gzip_min_length     512;
        gzip_buffers        8 64k;
        gzip_types          application/json
                application/javascript
                application/rss+xml
                application/vnd.ms-fontobject
                application/x-font
                application/x-font-opentype
                application/x-font-otf
                application/x-font-truetype
                application/x-font-ttf
                application/x-javascript
                application/xhtml+xml
                application/xml
                font/opentype
                font/otf
                font/ttf
                image/svg+xml
                image/x-icon
                text/css
                text/javascript
                text/plain
                text/xml;
        gzip_proxied        any;
        gzip_vary         on;
    PHP:
    sorry for OOT, anyone have using brotli?
     
    zuardin, Jun 23, 2018 IP
  4. hostechsupport

    hostechsupport Well-Known Member

    Messages:
    413
    Likes Received:
    23
    Best Answers:
    7
    Trophy Points:
    138
    #4
    You can the below snippet to the .conf file in order to enable Nginx gzip.

    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 application/javascript application/rss+xml application/vnd.ms-fontobject application/x-font application/x-font-opentype application/x-font-otf application/x-font-truetype application/x-font-ttf application/x-javascript application/xhtml+xml application/xml font/opentype font/otf font/ttf image/svg+xml image/x-icon text/css text/javascript text/plain text/xml;

    hope this helps :)
     
    hostechsupport, Jun 25, 2018 IP