zgo.at and the lighthouse score (cache policy)
Closed this issue · 3 comments
Hi! Thanks so much for the project and serving it offer it publicly. Before self-hosting it myself I'm trying your hosted version and I have a suggestion / improvement.
count.js
served from gc.zgo.at
doesn't have a long enough Cache TTL so that Lighthouse stops complaining and reducing the score.
Is this something you would consider increasing?
They recommend 1 year (Cache-Control: max-age=31536000
)
My lighthouse score is now 99 and this prevents my site from getting back to score of 100.
It's more of a bug than anything else that it's 90 days now; I set the cache to 90 days for the static files on the GoatCounter backend where it uses "cache buster" URL parameters ("/script.js?v=git-commit"), and that sort of accidentally got applied to count.js because it uses the same host. I can't add these parameters to count.js, because it's on your site not mine. I guess it's not that big of a deal as no one has complained and didn't notice until now, but I should set it to be much shorter timespan.
And setting it to a year really isn't going to make a difference for anyone; I mean, we're talking about a maximum saving of about 9k per year.
This is one case where an automated tool like lighthouse just doesn't have enough context to really decide what's reasonable; their help page mentions some of these caveats.
So I'll probably shorten it, but I can increase the TTL for the stable versions, as they will never change. You can also just serve count.js yourself; for example on my own site I just inline it in the HTML. The downside of that is you won't get any updates (the old versions are guaranteed to remain working, but you won't get new features or fixes).
And setting it to a year really isn't going to make a difference for anyone; I mean, we're talking about a maximum saving of about 9k per year.
to be clear, i don't care about savings as they are so low, but I do care about the lighthouse score. I had a perfect 100/100 and now it's reporting 99/100, oops!
I can inline it and I like that solution.
But still, i think the one you serve shouldn't affect the lighthouse score, don't you think? 1 year cache is too much?
Well, if I update count.js then some people won't get updates for up to a year. That seems rather long.
And Lighthouse scores are really just a heuristic; expecting every single static resource to have a cache expiry of a year is not realistic.