什么是gZip压缩? [英] What is gZip compression?

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

问题描述

我听说很多人应该使用 gZip 作为他们的网页,以加快访问和下载速度,同时也节省了带宽。



<那么,这个gZip压缩是什么?它是如何使下载更快?它是否压缩HTML和图像或只是HTML。



如果我要开始在我的webapps中使用gZip,我需要什么注意事项使?
是否有任何服务器或浏览器限制,或者它是否仅支持特定的编码。

解决方案 GZip是一种数据压缩形式 - 即它需要大量数据并使其变小。原始数据可以通过解压缩压缩文件来恢复。



它与Web应用程序和网站相关,因为HTTP协议包含gzip数据的能力,这意味着当它被使用时,您为该网站提供服务的带宽成本将会降低,因为访问该网站的用户将会下载较小的文件。

p>

使用GZip有一些注意事项,但总体而言,使用gzip通常比不使用gzip更好 - 例如,需要时间和处理器功能来压缩和解压缩文件,但通常这不是问题,因为执行此操作的时间通常少于通过下载较小文件保存的时间。因此,尽管浏览器不得不解压缩文件,但整体效果是节省时间的。



GZip可以压缩所有文件;它不会影响文件类型或编码。很显然,有些文件可以比其他文件更有效地压缩,因此节省的带宽将会有所不同 - HTML等文本文件会产生最佳效果;图像不会被gzip压缩太多,因为它们已经有一些内置的压缩​​。 gzip时,一些文件(例如已经大量压缩过的文件,如 .zip 文件)实际上可能会稍微大一些,因为它们不能再被压缩,但gzip仍然需要将元数据添加到文件中。但这些都是边缘情况,并没有太大区别。



跨HTTP的GZip通常完全透明。最终用户应该完全不知道它正在发生;浏览器会在幕后为他们做。从网络服务器端,只需打开Web服务器软件中的配置设置即可。从你的角度来看,这只是你需要知道的一切;只需在您的服务器上设置gzip设置(或询问您的ISP执行此操作)。很可能它已经在您的网站上处于活动状态,您甚至不知道。


I have heard a lot that one should use gZip for their webpages for faster access and downloads, and that it also saves the bandwidth.

So what is this gZip compression and how does it make the downloads faster ? Does it compress the HTML and images or just the HTML.

If I am to start using gZip in my webapps what considerations do I need to make ? Are there any server or browser restrictions for it, or does it support a particular encoding only.

解决方案

GZip is a form of data compression -- ie it takes a chunk of data and makes it smaller. The original data can be restored by un-zipping the compressed file.

It is relevant to web apps and web sites because the HTTP protocol includes the ability to gzip data that is being sent.

This means that when it is in use, your bandwidth costs for serving the site will be lower because people visiting the site will be downloading smaller files.

There are a few caveats to using GZip, but overall it's usually better to use gzip than not to -- for example, it does take time and processor power to zip and unzip the files, but typically this is not a problem because the time it takes to do that is often less than the time that is saved by downloading a smaller file. Therefore the overall effect is a time saving, despite the browser having to unzip the file.

GZip can compress all files; it doesn't make any difference what the file type is or the encoding. Obviously some files can be compressed more effectively than others, so the bandwidth saving will vary - text files like HTML give the best results; images are not compressed so much by gzip because they already have some compression built-in. Some files (eg those that are already heavily compressed like .zip files) may actually get slightly bigger when gzipped, because they can't be compressed any futher but gzip still needs to add it's meta data to the file. But these are edge cases, and don't make much difference.

GZip across HTTP normally happens completely transparently. The end user should be completely unaware that it is happening; the browser would do it behind the scenes for them. And from the web server end it is simply a matter of turning on a config setting in your web server software. From your perspective, that's really all you need to know; just set the gzip setting on your server (or ask your ISP to do it). It's quite possible it may already be active on your site without you even knowing.

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

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