Discover Centmin Mod today
Register Now

Nginx Nginx try to download and not gunzip .css and .js files

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by pamamolf, Jul 10, 2016.

Tags:
  1. pamamolf

    pamamolf Well-Known Member

    2,491
    229
    63
    May 31, 2014
    Ratings:
    +390
    Local Time:
    5:31 PM
    Nginx-1.13.x
    MariaDB 10.1.x
    Hi

    Was looking to enable compression .gz for .css and .js files....

    Using something like this browser try to download the gunzip files :(

    Code:
     location ~ \.css\.gz$ {
    
       add_header  Content-Encoding  gzip;
       gzip off;
       gzip_static on;
       gzip_proxied expired no-cache no-store private auth;
       expires 365d;
       types {
              text/css gz;
              text/css css;
              }
    }
    
    location ~ \.js\.gz$ {
    
       add_header  Content-Encoding  gzip;
       gzip off;
       gzip_static on;
       gzip_proxied expired no-cache no-store private auth;
       expires 365d;
       types {
              text/javascript gz;
              text/javascript js;
             }
    }   
    Any ideas?

    Thank you
     
    Last edited: Jul 10, 2016
  2. eva2000

    eva2000 Administrator Staff Member

    28,957
    6,573
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,755
    Local Time:
    12:31 AM
    Nginx 1.13.x
    MariaDB 5.5
    Static files are already compressed out of the box ;)

    Even for gzip static option
     
  3. pamamolf

    pamamolf Well-Known Member

    2,491
    229
    63
    May 31, 2014
    Ratings:
    +390
    Local Time:
    5:31 PM
    Nginx-1.13.x
    MariaDB 10.1.x
    What's the exact code that do that on nginx.conf?

    Is this one:

    Code:
            gzip on;
            gzip_vary   on;
            gzip_disable "MSIE [1-6]\.";
            gzip_static on;
            gzip_min_length   1400;
            gzip_buffers      32 8k;
            gzip_http_version 1.0;
            gzip_comp_level 5;
            gzip_proxied    any;
            gzip_types text/plain text/css text/xml application/javascript application/x-javascript application/xml application/xml+rss application/ecmascript application/json image/svg+xml;
    or anything else needed?

    Does it needs anything else if an https domain used?
     
    Last edited: Jul 10, 2016
  4. eva2000

    eva2000 Administrator Staff Member

    28,957
    6,573
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,755
    Local Time:
    12:31 AM
    Nginx 1.13.x
    MariaDB 5.5
    yup that's the code and nothing else needed - just works
     
  5. pamamolf

    pamamolf Well-Known Member

    2,491
    229
    63
    May 31, 2014
    Ratings:
    +390
    Local Time:
    5:31 PM
    Nginx-1.13.x
    MariaDB 10.1.x
    staticfiles.conf include must be active on the domain conf to get this work?
     
  6. eva2000

    eva2000 Administrator Staff Member

    28,957
    6,573
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,755
    Local Time:
    12:31 AM
    Nginx 1.13.x
    MariaDB 5.5
    nope :)
     
  7. pamamolf

    pamamolf Well-Known Member

    2,491
    229
    63
    May 31, 2014
    Ratings:
    +390
    Local Time:
    5:31 PM
    Nginx-1.13.x
    MariaDB 10.1.x
    Great thanks :)

    How can i verify that it works?
     
  8. eva2000

    eva2000 Administrator Staff Member

    28,957
    6,573
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,755
    Local Time:
    12:31 AM
    Nginx 1.13.x
    MariaDB 5.5
    • Like Like x 1