How do I gzip a WordPress site

optimization
Accelerate WordPress with gzip and mod_deflate

The two modules gzip (mod_gzip) and mod_deflate accelerate WordPress websites enormously by means of compression. The installation is very simple.

What is gzip

gzip is a compression program available for all computer operating systems. 90% of browsers support gzip compression. Thanks to the compression, HTML, Javascript, CSS, text, PHP or image files can be compressed.

Logically, this means that the data sent to the recipient is displayed less and the individual web pages are displayed faster in the browser. This saves between 40% and 70% of the transfer volume. The recipient will then enjoy fast websites.

mod_gzip must be loaded last in the module list, as Apache 1.3.x processes content in module order, and compression is the final step performed before data is sent.

mod_deflate

mod_deflate works together with gzip, but may only appear in the .htaccess file after gzip.

mod_deflate for Apache versions 2.0.44 and earlier comes with the compression ratio set for best speed, not best compression

Test websites for compression

There are some websites that you can use to quickly test whether your own (or another) website has already activated gzip and is delivering compressed data.

What do I have to do to use mod_gzip and mod_deflate?

Before you mod_gzip and mod_deflate In the first step, you have to determine whether your own web host or the package you are using provides the two modules. In my case, I just asked HostEurope support, the answer was "Yes!" And then it was sufficient to insert the two code snippets below into the file.

Code snippet for the .htaccess file

<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> <IfModule mod_deflate.c> 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 </IfModule>

More detailed information on gzip and mod_deflate