What is Gzip? Introduction to this method of compressing information in the network

Mr Site
6 min readNov 12, 2019

--

What is Gzip and its Usage? One way to compress files is to transfer them faster on the network, as well as a file format. Gzip reduces site size and speeds up site loading.

Introduction to Gzip compression

Compression reduces file size and allows the web server to view site users more quickly.

You must have already converted a zip or rar zip file into your system, and you know that the main purpose of these files is to compress the data so that it can be faster and easier to transmit than it is to get less volume, Gzip now It does the same for files on the site.

Smaller files allow your site visitors to receive site files faster and thus see your site faster. It should be noted that the Gzip function does not compress any file on the server side, compression is solely dependent on files such as HTML files, Stylesheets stylesheets, and JavaScript JavaScript, and does not include images and other available files.

How Gzip Works
When the user enters a site address in the browser, the first browser sends a request from the header, content-encoding: gzip, to check if the request is positive or negative. If the request is detected from the server and is positive, the server sends the compressed files to the browser, otherwise the server sends uncompressed, heavy files to the browser. All new browsers support Gzip.

How effective can Gzip be?
The advantage of using Gzip compression is that compressing your HTML and CSS files with Gzip usually saves about fifty to seventy percent of the file size. This means less time to load your pages and less bandwidth.

Is Gzip Active?
There are many sites and extensions to check for this feature, including the Varvy and Prorank sites, and the Wappalyzer browser extension.

How to enable Gzip Compression
Compression is enabled through the web server settings. Different web servers have different instructions that we will discuss below.

Gzip Activation in WordPress
You can use cache plugins that support this feature to enable Gzip in WordPress. Plugins like WP Rocket and W3 Total Cache automatically insert activation code into the site’s .htaccess file. Of course you need to have access to write to the .htaccess file.

Gzip Activation Training in Joomla!
To enable Gzip in Joomla, log in to Joomla! Then go to Site Menu> General Settings and in the Server tab, put Gzip compression on Yes and then save the changes.

Enable Gzip on htaccess
To enable Gzip in htaccess, first open the site’s .htaccess file and paste the code below, then save the changes.

Note: The .htaccess file is normally hidden and requires the Show hidden files feature to be enabled.

<ifModule mod_gzip.c>

mod_gzip_on Yes

mod_gzip_dechunk Yes

mod_gzip_item_include file. (html? | txt | css | js | php | pl) $

mod_gzip_item_include handler ^ cgi-script $

mod_gzip_item_include mime ^ text /.*

mod_gzip_item_include mime ^ application / x-javascript. *

mod_gzip_item_exclude mime ^ image /.*

mod_gzip_item_exclude rspheader ^ Content-Encoding:. * gzip. *

</ifModule>

دانلود اهنگ

Enable Gzip in Apache
The following code should be included in the .htaccess file as above.

AddOutputFilterByType DEFLATE text / plain

AddOutputFilterByType DEFLATE text / html

AddOutputFilterByType DEFLATE text / xml

AddOutputFilterByType DEFLATE text / css

AddOutputFilterByType DEFLATE application / xml

AddOutputFilterByType DEFLATE application / xhtml + xml

AddOutputFilterByType DEFLATE application / rss + xml

AddOutputFilterByType DEFLATE application / javascript

AddOutputFilterByType DEFLATE application / x-javascript

Enable Gzip on Nginx
To enable compression on the Nginx web server, you need to add the following code to your config file.

gzip on;

gzip_comp_level 2;

gzip_http_version 1.0;

gzip_proxied any;

gzip_min_length 1100;

gzip_buffers 16 8k;

gzip_types text / plain text / html text / css application / x-javascript text / xml application / xml application / xml + rss text / javascript;

# Disable for IE <6 because there are some known problems

gzip_disable “MSIE [1–6]. (?!. * SV1)”;

# Add a varying header for downstream proxies to avoid sending cached gzipped files to IE6

gzip_vary on;

خرید هاست

Gzip Activation Training in Litespeed
To enable compression on Litespeed web servers, go to Web Admin Console> Server> Tuning and check whether the enable compression option is enabled. If not, select the edit option and then enable this feature.

Try to enable the new mime type as follows:

Follow the path below in the Light Speed ​​Management Console:

Web Admin Console> Server> Tuning> GZIP Compression> Edit> Compressible Types

In this (Compressible Types) section of the new mime type, consider adding the application / json and save the changes and restart the lightweight graphical interface.

Gzip Activation in IIS
Go to the Select Role Services page from the server manager section, then open Web Server Options and then Performance, and make sure both Static Content Compression and Dynamic Content Compression are enabled.

Then open IIS Manager and click on the server name. Double-click the Compression option, tick the following two options on the pop-up screen, and click the Apply button on the right.

Enable Static Content Compression
Enable Dynamic Content Compression

Click on the name of the site you want and double-click on the compression option.

دانلود موزیک

You need to enable the settings in the web site configuration file as follows:

After making sure the web page compression module is installed on the server side, you now need to add the following code to the Web.Config site:

<system.webServer>

<httpCompression directory = ”% SystemDrive% \ inetpub \ temp \ IIS Temporary Compressed Files”>

<scheme name = “gzip” dll = “% Windir% \ system32 \ inetsrv \ gzip.dll” staticCompressionLevel = “9 ″ />

<dynamicTypes>

<add mimeType = “text / *” enabled = “true” />

<add mimeType = “message / *” enabled = “true” />

<add mimeType = “application / x-javascript” enabled = “true” />

<add mimeType = “application / javascript” enabled = “true” />

<add mimeType = “application / json” enabled = “true” />

<add mimeType = ”application / json; charset = utf-8 ″ enabled = ”true” />

<add mimeType = “application / atom + xml” enabled = “true” />

<add mimeType = “application / xaml + xml” enabled = “true” />

<add mimeType = “* / *” enabled = “false” />

</dynamicTypes>

<staticTypes>

<add mimeType = “text / *” enabled = “true” />

<add mimeType = “message / *” enabled = “true” />

<add mimeType = “application / x-javascript” enabled = “true” />

<add mimeType = “application / javascript” enabled = “true” />

<add mimeType = “application / json” enabled = “true” />

<add mimeType = ”application / json; charset = utf-8 ″ enabled = ”true” />

<add mimeType = “application / atom + xml” enabled = “true” />

<add mimeType = “application / xaml + xml” enabled = “true” />

<add mimeType = “* / *” enabled = “false” />

</staticTypes>

</httpCompression>

<urlCompression doStaticCompression = ”true” doDynamicCompression = ”true” />

</system.webServer>

Note: Here are the settings for how to enable compression of dynamic pages and static files. These settings include the location of the temporary files compressed by this module, as well as the mime types you want to compress. With these settings, only explicit mime types will be compressed and the other mime types will be ignored.

--

--