5

Some people say that to enable compression you modify htaccess file:

Others say you need to update httpd.conf file

What is the right way? If either is correct then wouldn't htaccess be a better choice since it doesn't require web server restart?

Community
  • 1
  • 1
dev.e.loper
  • 35,446
  • 76
  • 161
  • 247

2 Answers2

1

The Apache HTTP Server can be configured in a number of ways: The main configuration file is (usually) called "httpd.conf", but this file can include other configuration files with the "Include" directive. Furthermore, the HTTP Server allows for configuration files to be placed in the context path of your website. These decentral configuration files are (usually) called ".htaccess".

Configuration directives, like the directives to enable compression, can be valid in different contexts. The valid configuration contexts of the "AddOutputFilter", the "SetOutputFilter", and the (deprecated) "AddOutputFilterByType" all specify "server config, virtual host, directory, .htaccess" as their valid configuration contexts. Therefore, all of these directives can be used in the "httpd.conf" as well as in the ".htaccess" configuration files.

So both ways of configuring output compression are valid, and it's just a matter of taste whether you want all your server configuration in one central file (which gets only read during server (re)start) or whether want to spread the configuration in multiple files and directories (but get the benefit of changes being applied instantly).

philip
  • 11
  • 1
  • in defense of apache config, note that allowing .htaccess overrides increases runtime overhead - *every* time some page is accessed, apache has to check if any (and all) directories leading up to that file contain .htaccess (and if it has been changed, so it additionally needs to be parsed again). While it is not a great overhead (compared to others like PHP, CGI etc) apache config method does not have it, as it only reads config file when you request reload. It should only matter if you get a lots of hits, though. – Matija Nalis Apr 29 '15 at 13:19
0

If your Web Host is through C Panel Enable G ZIP Compression on Apache C Panel

  1. Go to CPanel and check for software tab.

  2. Previously Optimize website used to work but now a new option is available i.e "MultiPHP INI Editor".

  3. Select the domain name you want to compress.

  4. Scroll down to bottom until you find zip output compression and enable it.

  5. Now check again for the G ZIP Compression.

You can follow the video tutorial also. https://www.youtube.com/watch?v=o0UDmcpGlZI

Shree Sthapit
  • 196
  • 1
  • 7