Skip to main content

[转] Firefox 加速技巧

转载请注明出处:www.NiDaYe.orG,谢谢

作者:Roby Liang

很早很早以前曾经写过一篇“Firefox 终极加速”的文章,可以通过手动修改 user.js 文件来获取理论上的最佳浏览速度,后来发现这种修改方式对于普通用户来说真的有点勉为其难,而且国内的网络环境并不尽如人意,我们所做的 js 优化修改在臃堵的网路上显得那么渺小与无助。

不过聊胜于无,让我们暂且先把这些复杂的优化操作变的简单一点,然后再来亲自感觉一下这些已经在网络上流传了很久的提速技巧吧。下面的操作我们都在 about:config 里进行。在 Firefox 的地址栏中输入 about:config,让我们开始提速吧。

  • network.http.pipelining


  • 在 Filter 中输入 network.http.pipelining,双击赋值为 true,默认为 false。如果没有找到这个键值,可以右键新建一个 Boolean,把她赋值为 true 就 OK 了。

    还 是像我在从前解释过的那样,激活这个键值之后,Pipelining 同时发出成倍数的连接请求,从而达到提升连接速度的效果。网络上的大多数网站都是基于 HTTP 协议,而 HTTP 1.1 可以支持多线程的连接请求,通过这个操作可以减少 Firefox 载入网页的时间。不过并不是所有网页所在的服务器都支持这种操作,所以当你修改键值之后却看不到一点实际效果的时候,请不要对我破口大骂。

  • network.http.pipelining.maxrequests


  • 在 Filter 中输入 network.http.pipelining.maxrequests,双击并赋值为 8,默认键值为 4。

  • network.http.proxy.pipelining


  • 在 Filter 中输入 network.http.proxy.pipelining,双击并赋值为 true。

    这两条优化的道理同上,这里就不再多解释了。

  • network.dns.disableIPv6


  • 在 Filter 中输入 network.dns.disableIPv6,双击并赋值为 true。

    IPv6 把 IP 地址由 32 位增加到 128 位,从而能够支持更大的地址空间,当用户在终端向一个 IPv6-capable DNS 服务器发送连接请求时,也许服务器端会错误的返回给用户一个 IPv4 地址。而 Firefox 可以对这一切明察秋毫,不过在 Firefox 纠错的同时也必然会导致信号的延迟,所以这里我们把她赋值为 true,禁用掉她。

  • content.interrupt.parsing


  • 右键新建 Boolean 值,键名为 content.interrupt.parsing,赋值 true。

    默 认这个键值并不存在。我们激活这个键值之后,当目标网页载入时,Firefox 会根据一定频率打断解析的过程,不断的向用户反馈她所收集到的网页信息,有点像流媒体的意思。这时的 Firefox 很聪明,不会一根筋的一直钻牛角。在下面的内容中我还会具体讲一下这个键值的魅力所在。

  • content.max.tokenizing.time


  • 右键新建 Integer 值,键名为 content.max.tokenizing.time,赋值 2250000。

    这 个键值的作用其实就是指定一个循环事件的处理周期,这里的单位是微秒,要是我没有算错的话。理论上当我们将这个值取的越小,网页就会从视觉上载入的越流 畅,因为 Firefox 会在很短的单位时间里反馈回解析到的网页信息。可是这样无疑延迟了网页整体载入的时间,所以在这里我们不妨将这个周期取的大一些,理论上可以加速网页的载 入。

  • content.notify.interval


  • 右键新建 Integer 值,键名为 content.notify.interval,赋值 750000。

    载 入一个网页其实也是一门很大的学问。让我们来放一个慢动作,我们姑且先把在终端第一次收到的网页信息很不专业的叫做预载入页面吧,这个页面有可能是不完整 的图片或者文字,或者别的媒体文件。从我们第一次向远端主机发出连接请求到我们在终端收到这个预载入页面花费的时间,就是这里我们要定义的键值。理论上当 我们将这个时间设置的很低时,肯定会更快的拿到所谓的预载入页面,可这是一种杀鸡取卵的做法,这样无形中反而增加了我们整体页面的载入时间。按照官方的说 法,低于 100,000 将会降低 Firefox 的性能,那好吧,那我们把她彪到 750000 吧。

  • content.notify.ontimer


  • 右键新建 Boolean 值,键名为 content.notify.ontimer,赋值 true。

    为了使我们上面设置的 750000 微秒生效,还需要把这个键值激活。只有这两个键值配合,才会起作用。

  • content.notify.backoffcount


  • 右键新建 Integer 值,键名为 content.notify.backoffcount,赋值 5。

    这 个键值控制 Firefox 的内置计数器在归零之前载入页面返回的次数。我们将目标网页分成好多个部分进行下载,每下载完一个部分,计数器归零一次。-1 就是没有限制,值为 0 时这项功能被禁用。这里我们将她设置成 5, 当返回的次数达到五次而这部分网页还没有完全下载完时,那么剩下的没有下载完的网页内容将不会再按照我们预告设置的周期,像之前的五次那样一点一点的搬运 回来,而是会一次性的下载完。也就是说在这个部分的网页下载过程中,Firefox 一共向我们反馈了 6 次信息,前 5 次的时间间隔是我们在上面的键值中设置的周期 2250000 微秒,而第 6 次也就是最后一次则没有时间限制,什么时候把剩下的下完了,什么时候反馈回来。

    只有当我们在上面提到的 content.notify.ontimer 键值为 true 的时候,这里的设置才会生效。

  • content.switch.threshold


  • 右键新建 Integer 值,键名为 content.switch.threshold ,赋值 750000,也就是四分之三秒。

    在 前面我们提到了一个键值 content.interrupt.parsing,通过激活她实际上我们可以在载入页面的过程中跟 Firefox 产生互动,毕竟我们每一个人的心里都充满了爱。把 content.interrupt.parsing 激活后当页面载入时 Firefox 会有两种操作模式:高频和低频中断模式。使用高频模式时,网页回馈的频率也很高,我们坐在显示器前看到的网页载入过程也会更加的平滑。低频时网页回馈的频 率相对比较低,可是这时反而加快了网页载入的时间。当我们移动鼠标或者触击键盘时,高频模式被激活。在经过某一段时间我们没有碰鼠标和键盘,程序没有接到 鼠标和键盘发出的任何指令时,Firefox 就会自动进入低频模式工作,而这所谓的某一段时间,就是我们这里要指定的值。

  • nglayout.initialpaint.delay


  • 右键新建 Integer 值,键名为 nglayout.initialpaint.delay,赋值 0。

    这里实际上延迟了整个网页的显示速度,但是因为用户更喜欢在整个网页完全截入之前就开始阅读网页 (就像流媒体那样),所以在这里可以把值调为零,加速用户阅读网页的速度,有时候阅读速度和载入速度并不是成正比的。

    今天先写这些吧。在网络状况稳定的情况下这些优化的确是会起到一些效果的,并不光是心理作用,大家在为自己的浏览器提速时,也可以稍微参考一下。

    Comments

    Popular posts from this blog

    [转] UTF-8 and Unicode FAQ for Unix/Linux

    这几天,这个东西把我搞得很头疼 而且这篇文章好像太大了,blogger自己的发布系统不能发 只好用mail了 //原文 http://www.cl.cam.ac.uk/~mgk25/unicode.html UTF-8 and Unicode FAQ for Unix/Linux by Markus Kuhn This text is a very comprehensive one-stop information resource on how you can use Unicode/UTF-8 on POSIX systems (Linux, Unix). You will find here both introductory information for every user, as well as detailed references for the experienced developer. Unicode has started to replace ASCII, ISO 8859 and EUC at all levels. It enables users to handle not only practically any script and language used on this planet, it also supports a comprehensive set of mathematical and technical symbols to simplify scientific information exchange. With the UTF-8 encoding, Unicode can be used in a convenient and backwards compatible way in environments that were designed entirely around ASCII, like Unix. UTF-8 is the way in which Unicode is used under Unix, Linux, and similar systems. It is now time to make sure that you are well familiar

    Determine Perspective Lines With Off-page Vanishing Point

    In perspective drawing, a vanishing point represents a group of parallel lines, in other words, a direction. For any point on the paper, if we want a line towards the same direction (in the 3d space), we simply draw a line through it and the vanishing point. But sometimes the vanishing point is too far away, such that it is outside the paper/canvas. In this example, we have a point P and two perspective lines L1 and L2. The vanishing point VP is naturally the intersection of L1 and L2. The task is to draw a line through P and VP, without having VP on the paper. I am aware of a few traditional solutions: 1. Use extra pieces of paper such that we can extend L1 and L2 until we see VP. 2. Draw everything in a smaller scale, such that we can see both P and VP on the paper. Draw the line and scale everything back. 3. Draw a perspective grid using the Brewer Method. #1 and #2 might be quite practical. #3 may not guarantee a solution, unless we can measure distances/p

    Moving Items Along Bezier Curves with CSS Animation (Part 2: Time Warp)

    This is a follow-up of my earlier article.  I realized that there is another way of achieving the same effect. This article has lots of nice examples and explanations, the basic idea is to make very simple @keyframe rules, usually just a linear movement, then use timing function to distort the time, such that the motion path becomes the desired curve. I'd like to call it the "time warp" hack. Demo See the Pen Interactive cubic Bezier curve + CSS animation by Lu Wang ( @coolwanglu ) on CodePen . How does it work? Recall that a cubic Bezier curve is defined by this formula : \[B(t) = (1-t)^3P_0+3(1-t)^2tP_1+3(1-t)t^2P_2+t^3P_3,\ 0 \le t \le 1.\] In the 2D case, \(B(t)\) has two coordinates, \(x(t)\) and \(y(t)\). Define \(x_i\) to the be x coordinate of \(P_i\), then we have: \[x(t) = (1-t)^3x_0+3(1-t)^2tx_1+3(1-t)t^2x_2+t^3x_3,\ 0 \le t \le 1.\] So, for our animated element, we want to make sure that the x coordiante (i.e. the "left" CSS property) is \(