Text compression

Hello. I’ve already finished and uploaded my site, but after I checked my speed performance with Google insights and gmetrics, I noticed the main problem: text compression. Google offers to enable gzip compression, but it’s turned on already. I read that gzip doesn’t compress true fonts, so I changed ttf to woff. I know this format isn’t compressed too, but I was hoping it would be smaller in size at least. It didn’t really work, page performance on mobile is still no higher than 50. I wanted to try google fonts within blocs, but after reading the forum, I realized it isn’t the best idea. Idk what to do with that. Does anyone know a solution for text compression?

You either need to compress all in your server control panel, which I would not advise or include some htaccess code on the server that will compress fonts and key elements. Something like this should help. You can edit it as required:

#BEGIN Cache-Control Headers
<ifModule mod_headers.c>
<filesMatch "\.(ico|jpeg|jpg|webp|avif|png|gif|swf|pdf|svg|js|ttf|eot|woff|woff2|flv)$">
Header set Cache-Control "max-age=84600, public"
</filesMatch>
</ifModule>
#END Cache-Control Headers


#BEGIN Expire headers
<IfModule mod_expires.c>
  ExpiresActive On
 
  #Images
  ExpiresByType image/jpeg "access plus 1 year"
  ExpiresByType image/gif "access plus 1 year"
  ExpiresByType image/png "access plus 1 year"
  ExpiresByType image/webp "access plus 1 year”
  ExpiresByType image/avif "access plus 1 year"
  ExpiresByType image/svg+xml "access plus 1 year"
  ExpiresByType image/x-icon "access plus 1 year"
 
  #Video
  ExpiresByType video/mp4 "access plus 1 year"
  ExpiresByType video/mpeg "access plus 1 year"
 
  #CSS, JavaScript
  ExpiresByType text/css "access plus 1 month"
  ExpiresByType text/javascript "access plus 1 month"
  ExpiresByType application/javascript "access plus 1 month"


  # Web fonts

    # Embedded OpenType (EOT)
    ExpiresByType application/vnd.ms-fontobject         "access plus 1 month"
    ExpiresByType font/eot                              "access plus 1 month"

    # OpenType
    ExpiresByType font/opentype                         "access plus 1 month"

    # TrueType
    ExpiresByType application/x-font-ttf                "access plus 1 month"

    # Web Open Font Format (WOFF) 1.0
    ExpiresByType application/font-woff                 "access plus 1 month"
    ExpiresByType application/x-font-woff               "access plus 1 month"
    ExpiresByType font/woff                             "access plus 1 month"

    # Web Open Font Format (WOFF) 2.0
    ExpiresByType application/font-woff2                "access plus 1 month"

 
  # Others
  ExpiresByType application/pdf "access plus 1 month"
  ExpiresByType application/x-shockwave-flash "access plus 1 month"
</IfModule>
#END Expire headers

#START DEFLATE COMPRESSION
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE "application/atom+xml" \
"application/javascript" \
"application/json" \
"application/ld+json" \
"application/manifest+json" \
"application/rdf+xml" \
"application/rss+xml" \
"application/schema+json" \
"application/vnd.geo+json" \
"application/vnd.ms-fontobject" \
"application/x-font" \
"application/x-font-opentype" \
"application/x-font-otf" \
"application/x-font-truetype" \
"application/x-font-ttf" \
"application/x-font-woff" \
"application/x-font-woff2" \
"application/x-javascript" \
"application/x-web-app-manifest+json" \
"application/xhtml+xml" \
"application/xml" \
"font/eot" \
"font/otf" \
"font/ttf" \
"font/opentype" \
"image/bmp" \
"image/svg+xml" \
"image/vnd.microsoft.icon" \
"image/x-icon" \
"text/cache-manifest" \
"text/css" \
"text/html" \
"text/javascript" \
"text/plain" \
"text/vcard" \
"text/vnd.rim.location.xloc" \
"text/vtt" \
"text/x-component" \
"text/x-cross-domain-policy" \
"text/xml"
</IfModule>
#DEFLATE COMPRESSION


I just looked at your website and you should definitely add an SSL certificate. Some browsers will block access to websites without the certificate these days and it will hurt your Google ranking as well.

1 Like

thanks for answering. I already have htaccess file with this code. `

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 `

Do I need to change it for that you sent or add it?

About SSL certificate, the thing it’s actually added and turned on. At least that’s what my hosting says. But I see it isn’t protected too. It used to show it’s protected but at some point, after I reupload the site, it just disappeared. I guess I need to contact my hosting about that.

If I am reading your code correctly it is not compressing, so try my code instead. It is what I have used on various sites and it has always worked for me.

I see what is happening with your website now for the SSL. You do have a certificate installed, but you need to set up a redirect, so that everything goes to the SSL page. Your host should be able to help with that or I can let you have some htaccess code for that.

I added the code that you sent, but it doesn’t work too

I don’t know what kind of server you have but that should work with Apache servers. Perhaps you have Nginx or something else. I think this is something your webhost can help with if you ask them.

Sadly, it’s apache server, I contacted them and they said gzip is enabled on their sites by default. After I talked about text compression they gave me the code I sent here and said to try it. Meh, I have no idea what’s the problem then, I guess I need to contact them again. Thanks for the help.