优化Apache和Nginx服务器的带宽
2014年9月23日星期二
原文:
Optimizing for Bandwidth on Apache and Nginx
作者:Jeff Kaufman
每个人都希望节省带宽:托管服务提供商希望能够降低费用,而移动用户则不希望超出套餐流量,
没有人愿意在不需要的内容上浪费时间和带宽。网络上可节省带宽的地方比比皆是,随意就能举出几个例子:未经过gzip压缩的网页、未经过合并压缩的样式表和JavaScript以及未经优化的图片等。
那么,为什么网络没有针对带宽进行优化呢?如果节省带宽对每个人都有好处,为什么这些问题依然存在?很大程度上,这要归结为麻烦太多。我们鼓励网络设计师在导出作品时选择“另存为网页”格式,但他们有时会忽略这一点。JavaScript程序设计人员不喜欢使用经过合并压缩的代码,因为这会增加调试的难度。您可以设置自定义管道,以确保每一项这样的优化每次都可以作为开发或部署流程的一部分应用到您的网站,但这项工作相当艰巨。
网络用户可使用优化代理(如
Chrome
的代理)来轻松解决这一问题。当用户选择启用该服务时,其HTTP流量便会通过Google的代理传输,而该代理会优化网页加载并将带宽的使用量减少50%。虽然此方法对这类用户非常有用,但它仅适用于使用Chrome并启用了此功能的用户,而且不能优化HTTPS流量。
借助针对带宽进行优化
功能,PageSpeed小组将这种技术同样也提供给了网站站长,以便每个人都能从中获益:其中包括使用其他浏览器的用户、安全网站、桌面设备用户和想要降低出站流量支出的网站所有者。您只需在Apache或Nginx服务器上安装
PageSpeed模块
[1],然后
启用
配置中的“针对带宽进行优化”功能,PageSpeed就会为您搞定一切。
[1] 如果您使用的是其他网络服务器,可考虑在Apache或Nginx代理上运行PageSpeed。它完全
开放源代码
,并且我们正在努力开发针对
IIS
、
ATS
等服务器的移植功能。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2014-09-01。
[null,null,["最后更新时间 (UTC):2014-09-01。"],[[["The PageSpeed optimization tool helps reduce bandwidth usage by automatically optimizing website elements like images, stylesheets, and JavaScript files."],["PageSpeed offers an \"Optimize for Bandwidth\" feature, similar to Chrome's data compression proxy, to reduce bandwidth for all users, including those on different browsers and secure sites."],["Website owners can easily install the PageSpeed module on their Apache or Nginx servers and enable the \"Optimize for Bandwidth\" feature to benefit from these optimizations."],["Beyond basic bandwidth optimization, PageSpeed offers advanced features such as cache extension, inlining, image lazyloading, and deferred JavaScript execution, which can be enabled as needed."],["PageSpeed is open source and available for various web servers, with ongoing efforts to support even more platforms."]]],["Webmasters can reduce bandwidth usage for all users by installing the PageSpeed module on their Apache or Nginx server. This module, with the \"Optimize for Bandwidth\" feature enabled, automatically optimizes pages, similar to Chrome's optimizing proxy. This solution benefits all browsers, secure sites, and desktop users, reducing outbound traffic. The module can be configured for more advanced optimizations like cache extension, inlining, lazyloading, and deferring JavaScript. PageSpeed is also open-source, and porting efforts are underway for other web servers.\n"]]