keep-alive

vue项目优化

偶尔善良 提交于 2019-11-27 15:47:32
在日常的Vue项目开发中,随着业务的日渐复杂,代码量的日益增加,随之带来的问题就是打包后的vendor.js体积过大,导致加载时空白页时间过长,给用户的体验太差。为此我们需要减少vendor.js的体积,从本质上来解决这种问题。 这里大概例举几个在项目中实际用到过的方法,优化后的js大概缩小了50%左右,效果还是挺明显的。 1,webpack externals 为什么要配置externals 官方解释:webpack 中的 externals 配置提供了不从 bundle 中引用依赖的方式。解决的是,所创建的 bundle 依赖于那些存在于用户环境(consumer environment)中的依赖。 比如我们会在项目中引用各种第三方的js文件,如 jquery,vue,axios 等,如果我们在打包时排除这些依赖,则可以大大减小文件的大小,提高页面加载速度,配置方法如下: // 在 index.js 中引入资源 <script src="jquery.js"></script> <script src="vuex.js"></script> module.exports = { ... output: { ... }, externals : { jquery: 'jQuery' 'vue': 'Vue', } ... } 这样就剥离了那些不需要改动的依赖模块,换句话

【Vue实例生命周期】

ぐ巨炮叔叔 提交于 2019-11-27 15:19:22
目录 实例创建之前执行——beforeCreate 实例创建之后执行——created 挂载之前执行——beforeMount 挂载之后执行——mounted 数据更新之前执行——beforeUpdate 数据更新之后执行——updated 实例销毁之前执行——beforeDestroy 实例销毁之后执行——destroyed keep-alive组件激活时执行——activated keep-alive组件停用时执行——deactivated 原文: http://blog.gqylpy.com/gqy/278 "有时候,我们需要在实例创建过程中进行一些初始化的工作,以帮助我们完成项目中更复杂更丰富的需求开发,针对这样的需求,Vu e提供给我们一系列的钩子函数。 本文将详细介绍Vue实例在创建和销毁的过程中我们可以使用的钩子函数。 这是官方文档提供的Vue实例生命周期图,我们结合这张图来进行钩子函数的解析。 @ *** 实例创建之前执行——beforeCreate ==除标签外,所有的vue需要的数据(data)、事件(methods)、标签(el)都不存在.== <body> <div id="app"> {{ name }} <button @click="myClick">点击修改数据</button> </div> <script> new Vue({ el: '#app

【Vue实例生命周期】

别等时光非礼了梦想. 提交于 2019-11-27 15:17:20
目录 实例创建之前执行——beforeCreate 实例创建之后执行——created 挂载之前执行——beforeMount 挂载之后执行——mounted 数据更新之前执行——beforeUpdate 数据更新之后执行——updated 实例销毁之前执行——beforeDestroy 实例销毁之后执行——destroyed keep-alive组件激活时执行——activated keep-alive组件停用时执行——deactivated 原文: http://blog.gqylpy.com/gqy/278 "有时候,我们需要在实例创建过程中进行一些初始化的工作,以帮助我们完成项目中更复杂更丰富的需求开发,针对这样的需求,Vu e提供给我们一系列的钩子函数。 本文将详细介绍Vue实例在创建和销毁的过程中我们可以使用的钩子函数。 这是官方文档提供的Vue实例生命周期图,我们结合这张图来进行钩子函数的解析。 @ *** 实例创建之前执行——beforeCreate ==除标签外,所有的vue需要的数据(data)、事件(methods)、标签(el)都不存在.== <body> <div id="app"> {{ name }} <button @click="myClick">点击修改数据</button> </div> <script> new Vue({ el: '#app

KeepAlive with WCF and TCP?

做~自己de王妃 提交于 2019-11-27 13:55:42
问题 I have a Windows Service hosting an advanced WCF service that communicates over TCP(netTCP) with protobuf.net, some times also with certificates. The receiveTimeout is set to infinite to never drop the connection due to inactivity. But from what I understand the connection could be dropped anyway so I have created a simple two way keepalive service method that the client is calling every 9 min to keep the connection alive. It's very important that the connection never breaks. Is this the

setKeepAliveTimeout iOS behavior, exceeded 15 wakes in 300 sec

早过忘川 提交于 2019-11-27 12:57:18
I am writing a VOIP application on iOS 5 and I am trying to understand how the actual communication can stay alive while in the background. I understand there is a maximum amount of wakes the socket can get per amount of time. My problem is that my socket connection receive too many wakes messages, because of that the app is terminated with crash message: exceeded 15 wakes in 300 sec What I really don't understand is how is the socket supposed to be able to constantly send and receive data through it (for VOIP needs) if there is a limit for the amount of data it can receive per amount of time?

浅析HTTP/2的多路复用

◇◆丶佛笑我妖孽 提交于 2019-11-27 11:59:25
HTTP/2有三大特性:头部压缩、Server Push、多路复用。前两个特性意思比较明确,也好理解,唯有多路复用不太好理解,尤其是和HTTP1.1进行对比的时候,这个问题我想了很长时间,也对比了很长时间,现在把思考的结果分享出来,希望对大家有帮忙。 先来说说Keep-Alive 在没有 Keep-Alive 前,我们与服务器请求数据的流程是这样: 浏览器请求 //static.mtime.cn/a.js -->解析域名-->HTTP连接-->服务器处理文件-->返回数据-->浏览器解析、渲染文件 浏览器请求 //static.mtime.cn/b.js -->解析域名-->HTTP连接-->服务器处理文件-->返回数据-->浏览器解析、渲染文件 ... ... ... 这样循环下去,直至全部文件下载完成。 这个流程最大的问题就是: 每次请求都会建立一次HTTP连接 ,也就是我们常说的3次握手4次挥手,这个过程在一次请求过程中占用了相当长的时间,而且逻辑上是非必需的,因为不间断的请求数据,第一次建立连接是正常的,以后就占用这个通道,下载其他文件,这样效率多高啊!你猜对了,这就是 Keep-Alive 。 Keep-Alive 解决的问题 Keep-Alive 解决的核心问题:一定时间内,同一域名多次请求数据,只建立一次HTTP请求,其他请求可复用每一次建立的连接通道

How to change tcp keepalive timer using python script?

天涯浪子 提交于 2019-11-27 11:55:56
In my python script, I have activate TCP Keepalive using this command: x = s.setsockopt( socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) My goal is for socket connection to get closed, if there is no transmission(*) for 5 minutes. I am working on Windows and my python script is only receiving and not transmitting any data to client program. What I know is, by default, if no transmission will be there for 2 hours, then only I can close the connection using try and except. I know, for windows, I can manually reduce this waiting time by going to registry. But is there is a way by which, I can modify

How does Keep-alive work with ThreadPoolExecutor?

[亡魂溺海] 提交于 2019-11-27 11:39:51
In continuation to a question posted by me, I'm trying to use ThreadPoolExecutor in my codebase. Even after repeated attempts to comprehend from Java API doc, I failed to understand clearly the functionality/purpose behind keepAliveTime parameter to be passed in the constructor. Hope somebody can explain me with some good working example. Excerpts from Java doc: public ThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue) keepAliveTime - when the number of threads is greater than the core, this is the maximum time that

How to set the HTTP Keep-Alive timeout in a nodejs server

情到浓时终转凉″ 提交于 2019-11-27 10:52:18
I'm actually doing some load testing against an ExpressJS server, and I noticed that the response send by the server includes a "Connection: Keep-Alive" header. As far as I understand it, the connection will remain opened until the server or the client sends a "Connection: Close" header. In some implementations, the "Connection: Keep-Alive" header comes up with a "Keep-Alive" header setting the connection timeout and the maximum number of consecutive requests send via this connection. For example : "Keep-Alive: timeout=15, max=100" Is there a way (and is it relevant) to set these parameters on

Express.js close response

↘锁芯ラ 提交于 2019-11-27 09:40:22
Is there a way to close a response? I can use res.end() but it doesn't actually close the socket. What I want to achieve: I am writing a Java program which interfaces with the network, and I am writing a node.js server for this. Java code: String line; while((line = in.readLine()) != null) { System.out.println("RES: "+line); } But this just keeps hanging.. No end connection, still waiting for input from the socket. Node: exports.getAll = function (req, res) { res.set("Content-Type", "text/plain"); res.set(200); res.send(..data..); res.end(); } however res.end() does not close the connection..