Why am I doing this?
In short, for those who don’t know, Google has started measuring « Core Web Vitals » (Comment les seuils des métriques Core Web Vitals ont été définis | Articles | web.dev), which are values that help estimate whether a site is truly fast for the end user and provides a good experience (not a crappy site with content that constantly shifts due to loading images, ads, etc.).
Google uses these measurements to influence the site’s ranking in Google, so it is crucial to have a fast site.
The Web Vitals of the Gladys site (gladysassistant.com) are excellent (normal, it’s a fully static site and deployed on a CDN - Cloudflare), but the forum’s Web Vitals are not always great, as the forum is not static and hosted on a central server at Hetzner.
Here’s what I see on my side in Cloudflare (I use their tool to measure web vitals for end users):
As you can see, in 18% of cases it’s bad! This mainly affects mobile browsers when things don’t go well (people browsing the forum on their phones in the subway, for example).
So, we need to improve these numbers for these users!
One approach was to add a CDN to the forum. I used BunnyCDN, which is a « Pull » CDN. This means the forum replaces all URLs of static content with the CDN domain, and the CDN:
- On the first request, goes to the origin
- Then caches the file for all subsequent requests
This helps offload the forum from asset requests and also allows the user to load all static content from a server close to them 
Cloudflare also provides me with a list of file calls that are sometimes slow, and unsurprisingly: it’s images
The CDN will do all its work here for these files.
Now, there’s one thing I haven’t done yet. I need to « regenerate » all the forum posts to replace the image URLs in the posts with the CDN URL (I didn’t realize I had to do this myself :p).
I’ll keep you updated here on the evolution of the forum’s web vitals following these changes!