3

I have a Centos 7 installation with apache / httpd running.

I have some large .html and .txt documents which it serves.

How do I enable gzip compression with DEFLATE?


DEFLATE is present.

apachectl -t -D DUMP_MODULES |grep deflate
deflate_module (shared)

I added this to /etc/httpd/conf/httpd.conf:

<filesMatch "\.(js|html|css|txt)$">
    SetOutputFilter DEFLATE
</filesMatch>

Then restarted the server with:

systemctl restart httpd

This still indicates it's not enabled: http://www.whatsmyip.org/http-compression-test/

2 Answers 2

2

insert this code on your htaccess file from website in source "htdoc" or "www", if you not have htcaccess, you want to create it:

# compress text, html, javascript, css, xml: 

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

everything should go fine.

1

Put this line into your VirtualHost:

SetOutputFilter DEFLATE

If you want some exclusions, then for instance:

SetEnvIfNoCase Request_URI "\.(?:gif|jpe?g|png)$" no-gzip

For complete information about the DEFLATE module, visit this page.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.