Analytics & NGINX GZIP + HTTP2

Published on Mar 23, 2021
Topics: Meta, Statamic, NGINX

I added Plausible Anlaytics to the site just to see if any one is visiting (other than bots). Originally the plan was to use Fathom, but I make $0 doing this so I had to go with the cheaper option. I would bet that I don't continue using it past the 30 day free trial - not because of the product, but because I'm just not going to gain anything by having analytics.

It was simple enough to add to just the production site.

{{ if config:app:env == 'production' }}
    <script async defer data-domain="andybeesee.com" src="https://plausible.io/js/plausible.js"></script>
{{ /if }}

While doing that I noticed nothing was getting the GZIP treatment. Turns out that GZIP is on, but doesn't do anything until you define the gzip_types in /etc/nginx/nginx.conf

gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

Turns out we weren't even using HTTP2, so I added that inside /etc/nginx/sites-enabled/default.conf next to the listen lines.

listen [::]:443 ssl http2 ipv6only=on;
listen 443 http2 ssl;