mod_pagespeed有什么作用? [英] What does mod_pagespeed do?

查看:140
本文介绍了mod_pagespeed有什么作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是参考:

http://googlecode. blogspot.com/2011/01/go-daddy-makes-web-faster-by-enabling.html

但是我仍然不知道它在后台如何动态优化页面.

我不明白为什么缓存的后续请求很慢"的另一件事?

解决方案

PageSpeed mod_pagespeed是Apache服务器的一个模块,就像一个插件一样,并且由于Apache与IIS不同,因此无法将其安装在IIS服务器上. /p>

关于它的作用,它可以做很多事情:

  • 缩小(删除空格,注释等),换句话说,压缩外部CSS和JavaScript
  • 除了缩小JS之外,它还将多个外部JS文件组合到一个JS文件中,从而减少了HTTP请求或往返次数,因此页面加载速度更快
  • 优化文件的缓存.每个http标头都有一个缓存信息,换句话说,浏览器应该将资源保留多长时间,mod_pagespeed会优化该数字
  • 对新的JS文件使用URL指纹识别的想法.基本上,当mod_pagespeed优化并将多个JS文件合并为一个文件时,此临时文件存储在服务器上的某个位置,但是,其文件名是使用MD5之类的校验和算法从JS文件的内容生成的.这允许做的是mod_pagespeed告诉浏览器长时间存储JS文件(设置较长的缓存时间),但是由于校验和,开发人员会尽快甚至在其中一个JS文件中更改内容.所有文件都将更改,mod_pagespeed将生成一个新的临时JS文件,该文件的URL与旧文件相比将有所不同.因此,当保存了旧的合并JS文件的用户尝试重新加载页面时,由于新JS文件的URL将是新的,它将迫使浏览器再次下载它.因此,从本质上讲,这是进行缓存控制的一种方法.
  • 缩小HTML

因此,此模块非常酷.它确实可以提高网站的性能.但是,缺点之一是,它占用了服务器上更多的CPU资源.

希望这会有所帮助.

This is with reference to:

http://googlecode.blogspot.com/2011/01/go-daddy-makes-web-faster-by-enabling.html

But I still don't know how it works the in background to dynamically optimize pages.

One more thing I could NOT understand why "Cached subsequent requests are slow" ?

解决方案

PageSpeed mod_pagespeed is a module for Apache server which is just like a plug in, and since Apache is different from IIS, it cannot be installed on IIS servers.

As for what it does, it does multiple things:

  • Minifies (removes whitespace, comments, etc) or in other words compresses external CSS and JavaScript
  • In addition to minifying JS, it combines multiple external JS files into one JS file which causes less http requests or round trips so the page loads faster
  • Optimizes the cache for the files. Every http header has a cache information, or in other words, for how long should the browser keep the resource, mod_pagespeed optimizes this number
  • Uses the idea of URL fingerprinting for the new JS files. Basically when the mod_pagespeed optimizes and combines multiple JS files into one file, this temporary file is stored somewhere on the server, however, its filename is generated from the content of the JS files using checksum algorithms such as MD5. What this allows to do is that mod_pagespeed tells the browser to store the JS file for a long time (sets a long cache time), however as soon, as the developer will change the content even in one of the JS files, since the checksum of all the files will change, mod_pagespeed will generate a new temp JS file which will have a different URL compared to the old one. So, when the user who has saved the old combined JS file will try to reload the page, since the URL of the new JS file will be new, it will force the browser to download it again. So essentially this is one way to do cache control.
  • Minifies HTML

So this module is pretty cool. It can really speed up the performance of the sites. One downside however is that it uses much more CPU resources on the servers.

Hope this helps.

这篇关于mod_pagespeed有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆