Once you install WordPress and start creating documents which you want to present to your visitors, you might start worrying about the size of your HTML files. As you might already know, even blank spaces, carriage returns, new lines and tabs take some space. That means a document will load longer and take much more of your bandwidth and you don’t want any of that.
That’s where Output Compression comes as a hero. Because WordPress does not compress files this way on its own, it’s your task to make a conversation with your WP installation and politely ask WP to do so.
There are two ways of enabling Output Compression. In this article, we’re about to show you how to enable it via .htaccess file:
- Open .htaccess file
- Copy and paste the following code:
# Drop problematic browsers BrowserMatch ^Mozilla/4 gzip-only-text/html BrowserMatch ^Mozilla/4\.0 no-gzip BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
# Make sure proxies don't deliver the wrong content Header append Vary User-Agent env=!dont-vary
- Save changes
After you’re done with changes, you are also done with enabling Output Compression which will make your HTML documents much more lighter.
If you don’t like this method, you can do the same by using PHP code.