Web Hosting Q&As Logo
Web Hosting Q&As Part of the Q&A Network
Q&A Logo

How do I enable gzip compression on an Apache server?

Asked on Sep 09, 2025

Answer

To enable gzip compression on an Apache server, you need to use the `mod_deflate` module, which compresses content before sending it to the client, reducing bandwidth usage and improving load times.

    # Enable mod_deflate
    
      AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css
      AddOutputFilterByType DEFLATE application/javascript application/json
    
    
Additional Comment:
  • Ensure the `mod_deflate` module is enabled in your Apache configuration. You can enable it using the command `a2enmod deflate` on Debian-based systems.
  • Restart Apache after making changes to apply the new configuration using `systemctl restart apache2` or `service httpd restart` depending on your system.
  • Test the compression using online tools or browser developer tools to verify that gzip is working correctly.
  • Consider adding more MIME types to the configuration if needed, depending on the content your server delivers.
✅ Answered with Web Hosting best practices.

← Back to All Questions
The Q&A Network