Ok so I have the following inside my htacces file:
<IfModule mod_deflate.c>
# Compress HTML, CSS, JavaScript, Text, XML and fonts
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE font/opentype
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
# Remove browser bugs (only needed for really old browsers)
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent
</IfModule>
This is what gtmetrix says to put in and it has allways worked fine in the past. But for some reason both Gtmetrix and pagespeed still say that gzip is not enabled but on https://checkgzipcompression.com/ it says gzip is enabled.
Also removing the code then checking on checkgzip it does then say gzip is not enabled so it’s definitely working.
I was wondering if there was a reason for this. Has mod_deflate depreciated or something?
2
Answers
All that had to be done in the end was:
Within plesk "Websites & Domains" go to "Apache & nginx Settings" for the site in question.
At the bottom under "Additional nginx directives"
In the text area add the following
The code below should be added to your .htaccess file…
Save the .htaccess file and then refresh your webpage.
Check to see if your compression is working using the Gzip compression tool.
Enable compression on Apache webservers
The instructions and code above will work on Apache. If they are not working there is another way that may work for you. If the above code did not seem to work, remove it from your .htaccess file and try this one instead…
Enable compression on NGINX webservers
To enable compression in NGINX you will need to add the following code to your config file
Enable compression on Litespeed webservers
The ideal way to enable compression in Litespeed is to do it through the configuration under “tuning”. Just go down to “enable compression” and check to see if it is on, if not click “edit” then choose to turn it on.