HTTP Content Compression

Source: Internet
Author: User

One: HTTP content compression



Thinking: Content-length In previous studies, we know that the length of the body that represents the return

But here, why is the returned body length inconsistent with content-length?

The reason: Content-encoding:gzip this response header information in action.

Principle: In order to improve the transmission speed of web pages on the network, the server compresses the main information.

such as common gzip compression, deflate compression, compress compression, and Google Chrome are pushing SDCH compression.

The process of compression is like this


How do I enable the compression feature in Apache?

1: Turn on the deflate module, or the GZIP module

2: In the Conf file, write the following code

<ifmodule mod_deflate.c>

Deflatecompressionlevel 6 # Compression level 6, optional 1-9, 6 recommended

Addoutputfilterbytype DEFLATE Text/plain # Compressed text file

Addoutputfilterbytype DEFLATE text/html # compressing HTML files

Addoutputfilterbytype DEFLATE text/xml # Compressed XML

</ifmodule>

Why do you want to specify a file type to compress?

A: Compression is also to consume CPU resources, Pictures/videos and other files, compression effect is not good.

Generally compressed text format.

Before compression:









HTTP Content Compression

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.