[英]how to gzip or compress a .json file and use it in the frontend .js
i have big json file that i load in the index.js On page load (javascript) file which leads to increase in the time of loading the page. 我在index.js页面加载(javascript)文件中加载了一个很大的json文件,这导致加载页面的时间增加了。
What should i use to reduce this so that the page loads fast? 我应该使用什么来减少这种情况,以便快速加载页面?
You need to enable gzip on your server level, In configuration compressableMimeType you can specify which type of data to be compressed. 您需要在服务器级别启用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" />
You can visit http://viralpatel.net/blogs/enable-gzip-compression-in-tomcat/ for configuration steps 您可以访问http://viralpatel.net/blogs/enable-gzip-compression-in-tomcat/了解配置步骤
In your Apache configuration, set mod_deflate parameters. 在您的Apache配置中,设置mod_deflate参数。 See here for complete doc 查看完整的文档
Depending on your configuration, apache config could be located: 根据您的配置,可以找到apache config:
Windows C:\\Program Files\\Apache Group\\Apache2\\conf\\httpd.conf Linux: /etc/httpd/conf/httpd.conf Windows C:\\ Program Files \\ Apache Group \\ Apache2 \\ conf \\ httpd.conf Linux:/etc/httpd/conf/httpd.conf
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.