Enabling Compression for Your Website & Why It Matters
Compressing your files before serving them to your viewers is key for Search Engine Optimization (SEO). By compressing your files, you are essentially optimizing your viewers experience, and search engines like Google, prefer that.
In addition to SEO performance, it also provides other great benefits:
- Faster page loading for your visitors
- Less data transfer used on your web hosting account
"By compressing your files, you are essentially optimizing your viewers experience, and search engines like Google, prefer that."
Before you begin, this assumes you have mod_deflate enabled. Typically most cPanel installations, or shared web hosts will already have mod_deflate enabled.
Compressing HTML & Content
Make sure you place your .htaccess file in the root of your HTML directory (typically, public_html). Try to refresh your page to make sure the changes worked. If you get an error, mod_deflate is likely disabled and you will need to enable it or ask your Web Host to enable it for you.
Compressing PHP Files
output_handler = Off zlib.output_compression = On
Your php.ini file may be edited in your cPanel control panel. Search for "MultiPHP INI Editor", otherwise you can place the file directly in your HTML directory.
Once you have restarted saved your configuration files and restarted Apache, you can now test your sites compression. We recommend using https://checkgzipcompression.com/ to check if your site has compression enabled.