Welcome! Log In Create A New Profile

Advanced

Request big JS file very slow if enable gzip on

Posted by colky 
Request big JS file very slow if enable gzip on
October 26, 2014 08:47AM
I installed nginx-1.6.2-1.el6.ngx.x86_64 with yum on CentOS 6.5 system. below are my settings:

nginx.conf
--------------------------------------------------------------------------------------------------------------
http {
error_log /var/log/nginx/error.log debug;

.............
#added
limit_conn_zone $binary_remote_addr zone=addr:10m;
gzip on;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

upstream szsmk_dev {
ip_hash;
server 172.17.3.22:28080;
server 172.17.3.22:28180;
}


server {
listen 172.17.3.22:80 default_server;

location /wx/js/ {
root /home/developer/jboss/server/citycard_dev/deploy/citycard.war/;
}
location /wx/css/ {
root /home/developer/jboss/server/citycard_dev/deploy/citycard.war/;
}



location / {
limit_conn addr 1000;
proxy_pass http://szsmk_dev;
}

}

}
--------------------------------------------------------------------------------------------------------------
for others settings all are default.

Test page: http://dev.szsmk.com/wx/ticket/index
Test browser: Chrome (disabled cache)

when i disabled gzip and everything runs well, but if set gzip as on, i got below 3 different results if refresh the page in chrome.

1. very slow to load (80%)
Most times the page will need more than 20 ~ 60 seconds to be loaded. I checked and found mostly were blocked by http://dev.szsmk.com/wx/js/libs/jquery-ui-1.10.3.min.js (222KB) and http://dev.szsmk.com/wx/js/libs/angular/angular.min.js (105KB). For all other files which little than 100kb load very fast.

error.log:
2014/10/26 20:44:30 [info] 20917#0: *80 client 49.73.183.141 closed keepalive connection
2014/10/26 20:44:30 [info] 20917#0: *83 client 49.73.183.141 closed keepalive connection
2014/10/26 20:44:30 [info] 20917#0: *82 client 49.73.183.141 closed keepalive connection
2014/10/26 20:44:30 [info] 20917#0: *85 client 49.73.183.141 closed keepalive connection

2. Response error: (10%)

for jquery-ui-1.10.3.min.js or angular.min.js, often got below error when request:

in browser shows: "(failed) net::ERR_EMPTY_RESPONSE"


in error.log shows:
2014/10/26 20:27:13 [info] 20917#0: *28 client prematurely closed connection (104: Connection reset by peer) while sending response to client, client: 49.73.183.141, server: , request: "GET /wx/js/libs/jquery-ui-1.10.3.min.js HTTP/1.1", host: "dev.szsmk.com", referrer: "http://dev.szsmk.com/wx/ticket/index"


3. load success(10%)
Sometimes i will can load the page success within 10 seconds

Anybody can tell me how to enable gzip and resolve the issue?



Edited 2 time(s). Last edit at 10/26/2014 08:53AM by colky.
Re: Request big JS file very slow if enable gzip on
November 02, 2014 08:17PM
You can add to your nginx.conf

gzip_static on;
gzip on;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript text/x-js;
gzip_comp_level 2;
gzip_min_length 1000;
gzip_buffers 16 8k;
gzip_vary on;
gzip_http_version 1.0;
gzip_disable msie6;
gzip_proxied any;

You location blocks are not working i see your java scripts being delivered from jboss not nginx.

curl -I dev.szsmk.com/wx/js/libs/jquery-2.0.2.min.js
HTTP/1.1 200 OK
Server: nginx
Date: Mon, 03 Nov 2014 01:02:29 GMT
Content-Type: text/javascript;charset=UTF-8
Content-Length: 83380
Connection: keep-alive
X-Powered-By: Servlet 2.4; JBoss-4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200807181417)/JBossWeb-2.0
ETag: W/"83380-1414073457000"
Last-Modified: Thu, 23 Oct 2014 14:10:57 GMT

try these location blocks

location ~ ^/wx/js/ {
root /home/developer/jboss/server/citycard_dev/deploy/citycard.war/;
}

location ~ ^/wx/css/ {
root /home/developer/jboss/server/citycard_dev/deploy/citycard.war/;
}
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 176
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready