【发布时间】:2018-08-08 09:28:12
【问题描述】:
我有很大的 json 文件,我在 index.js 中加载页面加载 (javascript) 文件,这会导致加载页面的时间增加。
我应该使用什么来减少这种情况以使页面加载更快?
【问题讨论】:
-
我已经添加了这个,但它仍然无法正常工作
标签: javascript json apache tomcat gzip
我有很大的 json 文件,我在 index.js 中加载页面加载 (javascript) 文件,这会导致加载页面的时间增加。
我应该使用什么来减少这种情况以使页面加载更快?
【问题讨论】:
标签: javascript json apache tomcat gzip
您需要在服务器级别启用 gzip,在配置 compressableMimeType 中您可以指定要压缩的数据类型。
<Connector port="8090" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8444"
compression="on" compressableMimeType="text/html,
text/xml,text/plain,text/javascript,text/css,application/json" />
您可以访问http://viralpatel.net/blogs/enable-gzip-compression-in-tomcat/了解配置步骤
【讨论】:
在您的 Apache 配置中,设置 mod_deflate 参数。 See here for complete doc
根据您的配置,可以定位 apache 配置:
Windows C:\Program Files\Apache Group\Apache2\conf\httpd.conf Linux:/etc/httpd/conf/httpd.conf
【讨论】: