【性能】web提升性能的小总结
2015-03-16 11:40
405 查看
1. 异步加载js文件,判断文件是否已加载,不重复加载
2. 合并文件
合并css文件及图片;
切割js文件,分清类别:1)初始加载, 2)按需加载
3. 服务器端 , 配置以apache为例
1)启用gzip 压缩传输文件
开启模块:
LoadModule deflate_module modules/mod_deflate.so
LoadModule headers_module modules/mod_headers.so
备注:deflate模块采用的是哈夫曼编码
服务器配置增加:
2) 加入失效时间,没验证成功
开启模块:
LoadModule expires_module modules/mod_expires.so
服务器配置:
if (typeof echarts === 'undefined') { console.log('异步加载echarts'); $.getScript(_relyScripts, function () { _this.showWhLatencyData(); }); }else { console.log('已加载echarts'); _this.showWhLatencyData(); }
2. 合并文件
合并css文件及图片;
切割js文件,分清类别:1)初始加载, 2)按需加载
3. 服务器端 , 配置以apache为例
1)启用gzip 压缩传输文件
开启模块:
LoadModule deflate_module modules/mod_deflate.so
LoadModule headers_module modules/mod_headers.so
备注:deflate模块采用的是哈夫曼编码
服务器配置增加:
<IfModule mod_deflate.c> SetOutputFilter DEFLATE SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary SetEnvIfNoCase Request_URI .(?:pdf|doc|avi|mov|mp3|rm)$ no-gzip dont-vary AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css AddOutputFilterByType DEFLATE application/x-java script <IfModule mod_headers.c> Header append Vary User-Agent <FilesMatch ".(html|htm)$"> Header set Cache-Control "max-age=86400" </FilesMatch> <FilesMatch ".(js|css|txt)$"> Header set Cache-Control "max-age=259200" </FilesMatch> <FilesMatch ".(jpg|jpeg|png|gif|swf)$"> Header set Cache-Control "max-age=259200" </FilesMatch> <FilesMatch ".(pl|php|cgi|spl|scgi|fcgi)$"> Header unset Cache-Control </FilesMatch> </IfModule> </IfModule>
2) 加入失效时间,没验证成功
开启模块:
LoadModule expires_module modules/mod_expires.so
服务器配置:
<IfModule mod_expires.c> ExpiresActive On ExpiresDefault A600 ExpiresByType image/x-icon "access plus 2 month" ExpiresByType application/x-javascript "now plus 2 day" ExpiresByType text/css "now plus 2 day" ExpiresByType image/gif "access plus 2 month" ExpiresByType image/png "access plus 2 month" ExpiresByType image/jpeg "access plus 2 month" ExpiresByType text/plain "access plus 2 month" ExpiresByType application/x-shockwave-flash "access plus 2 month" ExpiresByType video/x-flv "access plus 2 month" ExpiresByType application/pdf "access plus 2 month" ExpiresByType text/html "now plus 1 day" </IfModule>
相关文章推荐
- 如何提升Web后端性能?我的4个实践和总结(2017-02-06 张弸中)
- 提升Web性能的8个技巧总结
- 提升Web性能的8个技巧总结
- 提升Web性能的8个技巧总结
- 提升Web性能的8个技巧总结
- 提升Web性能的8个技巧总结
- Web应用性能提升总结
- (总结)Web性能压力测试工具之WebBench详解
- webpack学习教程之前端性能优化总结
- WEB站点性能优化实践(加载速度提升2s)
- WEB站点性能优化实践(加载速度提升2s) 推荐
- Web服务端性能提升实践
- web 前端页面性能优化总结
- 关于 Java Web 项目性能提升的一些思路
- 【摘抄】提升web程序性能-前端
- web应用性能优化经验总结
- (总结)Web性能压力测试工具之WebBench详解
- web应用中使用缓存提升性能的8种武器
- paip.提升安全性--360,WI,AWVS三款WEB程序安全检测软件使用总结
- Java的WEB应用性能问题定位方法总结:常见的性能指标分析 .