For some unexpected reason, my nginx server responses static files (like .css
and .js
) for too long time. For example, there are some connected scripts and stylesheets on page with filesize less than 10kb. Chrome devtools timeline profiling shows, that those files are downloaded for about 15+ seconds (see screenshot below).
What can be a reason for responsing static files such a long time?
Important update. I noticed, that it happens only on html pages. If to open any js or css file singulary, it loads fastly, as it's actually expected.
I use nginx+apache bundle on my server, and nginx is responsible for all the static files, such as js, css, images and etc..
Thx in advance.
My problem was caused by DDoS-protection (ngx_http_limit_req_module), which was configured incorrectly. I have inadvertently copy-pasted nginx config somewhere from internet onto my server (so, everything worked fine, excepting the page loading time). Thx god I've got a point to check nginx error log, in which were warnings like
2017/01/12 04:14:33 [warn] 21347#21347: *120 delaying request, excess: 0.975, by zone "my_host", client: my_ip_address, server: my_host, request: "GET JS_OR_CSS_SCRIPT_URI HTTP/1.1", host: "my_host", referrer: "page_url_which_was_requesting_js_or_css"
So, googling helped to configure limit_req_zone
and limit_req
correctly:
http {
limit_req_zone $host zone=hostreqlimit:20m rate=1500r/m;
...
server {
...
limit_req zone=hostreqlimit burst=2500 nodelay;
...
}
}
Sorry for a silly question c: