Optimizing my yunohost wordpress blog

After my last update about my blog migration, basically all I did was install LiteSpeed Cache plugin and mess around with it.

For reference, lots of documentation goodness here

The most important part to note is that I kept getting bugged by both Google’s PageSpeed Insights and GTmetrix to enable text compression.

After some time reading about compression and Marco Saric’s post, I tried to enable compression by adding some lines of code at the bottom of the .htaccess file (accessible by the plugin through: LiteSpeed Cache->Toolbox->Edit .htaccess ):

<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*

This didn’t work and realized that gzip doesn’t come enabled by default (most things were commented out) in yunohost’s nginx installation. So I referred to this link and edited the file /etc/nginx/nginx.conf :

gzip on;

add_header Content-Encoding "gzip2";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript

The line

add_header Content-Encoding "gzip2";

is the most important, after that my blog was tested for compression using: https://www.giftofspeed.com/gzip-test/ and https://varvy.com/tools/gzip/ , both test websites see compression enabled.

I’m still not sure about Google’s PageSpeed Insights but GTmetrix sees it as well. Here are my results (for now):

Google’s PageSpeed Insights

Just for fun (haven’t looked too much into this yet) I am adding the score for Website carbon as well:

So far I am more or less happy with the results and there is room for improvement. Some settings seem to break my Indieweb and ActivityPub plugins.

Day 15 of

By lopeztel

Mexican, wannabe maker and overall linux distro enthusiast. I enjoy playing around with electronics, running, painting and reading. I started blogging as therapy and got more invested recently.


Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.