apache tutorial - Data Compression Using the Apache Mod_Deflate Module - apache - apache web server - apache server - apache2
- Increase website performance using the apache mod_deflate module
- we can use compression tester ( compressiontest gzip ) to reduce page load times and the amount of bandwidth our site uses.
- This can be achieved via gzip compression

How to enable data compression using the mod_deflate module
- Below are the steps to enable data compression by apache config location mod_deflate module in your .htaccess file.
Using data compression with the Apache mod_deflate module:
- We can use the apache mod_deflate module to compress output from our web site that is sent to client browsers.
- Using data compression can reduce page load times and the amount of bandwidth our site uses which can be tested via gzip test
- enable gzip compression - To enable data compression with the mod_deflate module, use a text editor to edit the .htaccess file.
content encoding gzip example:

- Below code configures apache server that demonstrates one way to enable data compression by specifying file extensions (mod_deflate):
<IfModule mod_deflate.c>
<filesMatch "\.(js|css|html|php)$">
SetOutputFilter DEFLATE
</filesMatch>
</IfModule>
click below button to copy the code. By Apache tutorial team
- In this example, apache server compresses any file that has an extension of .js, .css, .html, or .php.
- Alternatively apache web server use MIME types to specify which files to compress.
- The sample configuration demonstrates as the following:
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css text/javascript application/javascript
</IfModule>
click below button to copy the code. By Apache tutorial team
- In this example, Apache compresses any file that uses one of the MIME types referenced by the AddOutputFilterByType directive.
- To disable data compression, we can delete the relevant lines in the .htaccess file, or comment them out by preceding each line with #.
