Skip to content
李昌文 edited this page Nov 10, 2018 · 4 revisions

优化访问速度

开启 Gzip

  1. 方法一:在 one-main 的 application.yml 中添加配置压缩Http请求
server:
  compression:
    enabled: true
    mime-types: text/html,text/xml,text/plain,text/css,text/javascript,application/javascript
  1. 方法二:在Nginx中启用Gzip
http {
	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_min_length 256;
	gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/vnd.ms-fontobject application/x-font-ttf application/font-woff2 font/opentype image/svg+xml image/x-icon;

	......
}

开启缓存(默认开启缓存)

  1. 打包到one-main中运行之后,HttpCacheFilter会对js\css\图片等静态资源添加缓存头部,让浏览器缓存这些静态资源。
  2. 也可以在Nginx中启用缓存