The mod_deflate module provides the DEFLATE output filter that allows output from your server to be compressed before being sent to the client over the network.
To enable deflate_module typ
a2enmod deflate
Now to activate the new configuration, you need to run:
systemctl reload apache2
To compress all these files you can add deflate_module option in your .htaccess file
<IfModule deflate_module>
AddOutputFilterByType DEFLATE text/html text/css text/plain text/html text/xml image/gif image/jpeg image/png image/ico text/javascript application/x-javascript application/javascript application/json application/pdf
</IfModule>
or use this if you don't what to compress images or PDF files
<IfModule deflate_module>
AddOutputFilterByType DEFLATE text/html text/css text/plain text/html text/xml text/javascript application/x-javascript application/javascript application/json
</IfModule>
Previous page: Enable rc.local shell script
Next page: htaccess Disable Browser To Prompt Open/Save As Option