I recently noticed that Google PageSpeed was complaining to me about “Enable text compression” for my CapRover applications.
To enable gzip compression in CapRover, it’s not enough to enable it on your application web server inside your Docker container, you also need to enable it in the global CapRover Nginx proxy server.
To do so, go to Settings > Base Config Location in nginx container
Go down to the line that says # gzip on;
Replace it with the following:
gzip on;
gzip_types
text/plain
text/css
text/js
text/xml
text/html
text/javascript
application/javascript
application/x-javascript
application/json
application/xml
application/xml+rss
application/rss+xml
image/svg+xml/javascript;
gzip_vary on;
Press Save and Update and wait for Nginx to reload.
Your config should now look like this:
Verify using curl
(Replace example.org
with your site URL):
curl -H "Accept-Encoding: gzip" https://example.org --output -
If you see garbled output in the console, it means gzip is now enabled!