为了减少开销,把webapp单独部署到linux文件夹中,和后端分离出来,于是用了nginx的静态目录功能。
location /webapp/myapp/ {
root /usr/share/nginx/html/;
}
然鹅,测试访问,明显感受到了比放在后端代码托管中更慢。
优化
gzip on;
gzip_min_length 1k;
gzip_buffers 4 8k;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_vary off;
gzip_types text/plain application/x-javascript text/css application/javascript application/json application/xml image/jpeg image/gif image/png;
gzip_disable "MSIE [1-6]\.";
open_file_cache max=1000 inactive=300s;
open_file_cache_valid 360s;
open_file_cache_min_uses 2;
open_file_cache_errors off;
server {
listen [::]:80;
listen 80;
location /webapp/myapp/ {
root /usr/share/nginx/html/;
expires 30d;
}
}
1.gzip压缩
2.文件缓存