# A CDN for the forum's static assets!

**URL:** <https://community.gladysassistant.com/t/un-cdn-pour-les-assets-statiques-du-forum/6569>\
**Category:** Actualités\
**Created:** [October 8, 2021, 9:56am UTC](https://community.gladysassistant.com/t/un-cdn-pour-les-assets-statiques-du-forum/6569 "2021-10-08T09:56:35Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [October 8, 2021, 9:56am UTC](https://community.gladysassistant.com/t/un-cdn-pour-les-assets-statiques-du-forum/6569/1 "2021-10-08T09:56:36Z")

</div>

Hello everyone 🙂

Just a quick message to let you know, I’ve deployed a CDN to manage the forum’s assets (CSS/JS/icons/images)

It’s pretty simple, but I realized that the forum was making a lot of requests to load the CSS/JS/icons/images and it was a shame that these requests were made on the origin and not on a CDN close to the user.

Some pages load a lot of static resources, and it’s better to offload the forum’s backend so it can focus on dynamic content 🙂

The goal is also to improve the forum’s Web Vitals to rank better on Google.

(Also, for users like me in Asia, this greatly improves loading times 😇 )

To set this up, Discourse offers a turnkey configuration, which I deployed very simply. I used Bunny CDN as the CDN.

For now, everything is working, but if you notice any loading bugs at any time, let me know 🙂

---

<div class="post-metadata">

**Author:** ![lmilcent](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/lmilcent/32/7023_2.png) [@lmilcent](https://community.gladysassistant.com/u/lmilcent)\
**Post date:** [October 8, 2021, 10:58am UTC](https://community.gladysassistant.com/t/un-cdn-pour-les-assets-statiques-du-forum/6569/2 "2021-10-08T10:58:29Z")

</div>

Great idea!  
_So far so good…_

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [October 8, 2021, 11:11am UTC](https://community.gladysassistant.com/t/un-cdn-pour-les-assets-statiques-du-forum/6569/3 "2021-10-08T11:11:05Z")

</div>

First minor issue (oops), as the CDN contacts the forum with the same IP (it’s a «&nbsp;pull&nbsp;» type CDN, so the cache needs to «&nbsp;warm up&nbsp;»), the forum’s internal rate limit (Nginx) sometimes blocks the CDN with 429 Too Many Requests.

For now, it hasn’t happened too much, but I’ve seen a few go through:

 ![Screenshot 2021-10-08 at 19.09.02](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/3/3c95fc2448e21f1bab252713908508caef86be77.png)

I’m restarting the forum with the fix!

---

<div class="post-metadata">

**Author:** ![GBoulvin](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/gboulvin/32/10006_2.png) [@GBoulvin](https://community.gladysassistant.com/u/GBoulvin)\
**Post date:** [October 8, 2021, 12:55pm UTC](https://community.gladysassistant.com/t/un-cdn-pour-les-assets-statiques-du-forum/6569/4 "2021-10-08T12:55:01Z")

</div>

Not yet, 6 PM… 😅

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [October 9, 2021, 12:44am UTC](https://community.gladysassistant.com/t/un-cdn-pour-les-assets-statiques-du-forum/6569/5 "2021-10-09T00:44:27Z")

</div>

The cache is gradually filling up all over the world 🙂

 ![Screenshot 2021-10-09 at 08.42.27](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/b/b57eaf89bdf15412620c331985d650440768a1c8.png)

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [October 9, 2021, 1:05am UTC](https://community.gladysassistant.com/t/un-cdn-pour-les-assets-statiques-du-forum/6569/6 "2021-10-09T01:05:57Z")

</div>

Why am I doing this?

In short, for those who don’t know, Google has started measuring «&nbsp;Core Web Vitals&nbsp;» ([Comment les seuils des métriques Core Web&nbsp;Vitals ont été définis &nbsp;|&nbsp; Articles &nbsp;|&nbsp; web.dev](https://web.dev/defining-core-web-vitals-thresholds/)), 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](http://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):

 ![Screenshot 2021-10-09 at 08.58.01](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/1/1941a432880616b26c8b10185dff030ce7ea112b.png)

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 «&nbsp;Pull&nbsp;» 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.

 ![Screenshot 2021-10-09 at 08.58.15](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/d/d6d2f28ddf2dcd3df8a1be24898cda9c2b2a6cf6.png)

Now, there’s one thing I haven’t done yet. I need to «&nbsp;regenerate&nbsp;» 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!

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [October 9, 2021, 1:16am UTC](https://community.gladysassistant.com/t/un-cdn-pour-les-assets-statiques-du-forum/6569/7 "2021-10-09T01:16:34Z")

</div>

Quick question then, as users, does the forum seem fast or not on a daily basis?

@VonOx @AlexTrovato @lmilcent @terdious you who are quite active, I’m open to any feedback on your experience with the forum 😃

---

<div class="post-metadata">

**Author:** ![VonOx](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/vonox/32/10128_2.png) [@VonOx](https://community.gladysassistant.com/u/VonOx)\
**Post date:** [October 9, 2021, 4:46am UTC](https://community.gladysassistant.com/t/un-cdn-pour-les-assets-statiques-du-forum/6569/8 "2021-10-09T04:46:47Z")

</div>

It’s up to me

---

<div class="post-metadata">

**Author:** ![AlexTrovato](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/alextrovato/32/10705_2.png) [@AlexTrovato](https://community.gladysassistant.com/u/AlexTrovato)\
**Post date:** [October 9, 2021, 5:57am UTC](https://community.gladysassistant.com/t/un-cdn-pour-les-assets-statiques-du-forum/6569/9 "2021-10-09T05:57:14Z")

</div>

I had some latency yesterday on the first page refresh, but after that, I didn’t notice anything.

---

<div class="post-metadata">

**Author:** ![Terdious](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/terdious/32/6316_2.png) [@Terdious](https://community.gladysassistant.com/u/Terdious)\
**Post date:** [October 9, 2021, 6:34am UTC](https://community.gladysassistant.com/t/un-cdn-pour-les-assets-statiques-du-forum/6569/10 "2021-10-09T06:34:35Z")

</div>

For my part, it’s the same, it’s fluid enough to have a good experience, whether on mobile or PC, knowing that I often only have poor 4G connection.  
If you need the \*.har files, I can send them to you by email, I have done the home page and the Latest French page.  
Like @AlexTrovato, it happens that the home page takes a little longer to load after clearing the cache (between 5 and 10 seconds) but I really blame that on my connection!!

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [October 9, 2021, 6:46am UTC](https://community.gladysassistant.com/t/un-cdn-pour-les-assets-statiques-du-forum/6569/11 "2021-10-09T06:46:21Z")

</div>

Okay, thanks for your feedback!

@Terdious no need, I already have a lot of metrics via Cloudflare analytics, I’ll monitor the progress 🙂

I’ll post the progress here in the coming weeks.

Knowing that on the Google search console side, I also have a pretty average rating for the forum, which I hope will improve with these changes 🙂

---

<div class="post-metadata">

**Author:** ![lmilcent](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/lmilcent/32/7023_2.png) [@lmilcent](https://community.gladysassistant.com/u/lmilcent)\
**Post date:** [October 9, 2021, 6:50am UTC](https://community.gladysassistant.com/t/un-cdn-pour-les-assets-statiques-du-forum/6569/12 "2021-10-09T06:50:18Z")

</div>

On my end, I’ve never had any latency issues, so I didn’t notice any particular change. 😅  
But it’s rather good news in the end!

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [October 9, 2021, 6:55am UTC](https://community.gladysassistant.com/t/un-cdn-pour-les-assets-statiques-du-forum/6569/13 "2021-10-09T06:55:20Z")

</div>

For information, I will be launching the re-generation of all posts with images via the CDN, which will take a little while (about fifteen minutes I think), and the forum may be a bit slow during this time 🙂

Yesterday I just moved all static assets (JS/CSS/icons) + images from new posts, and now it will also be the images from previously written posts!

> [@lmilcent](#):
>
> On my side I’ve never had any latency issues, so I didn’t notice any particular change. 😅

Actually, I think the problems are rather for some users who find the forum via Google and land on a very long post with tons of photos.

**Example:** the tutorial «&nbsp;Flasher un Sonoff&nbsp;» on the forum is very well referenced on Google and drives a lot of traffic to the forum every day 😃 Except that users arrive out of nowhere, have nothing in local cache, and have to load all the images (including icons, css, js).

So doing it via a CDN close to them allows to speed up the loading times for these people.

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [October 9, 2021, 7:00am UTC](https://community.gladysassistant.com/t/un-cdn-pour-les-assets-statiques-du-forum/6569/14 "2021-10-09T07:00:35Z")

</div>

It’s working!!

 ![Screenshot 2021-10-09 at 14.59.33](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/4/48ff14f39baeed0aaa31df25c436bafc21ec5f9b.jpeg)

---

<div class="post-metadata">

**Author:** ![AlexTrovato](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/alextrovato/32/10705_2.png) [@AlexTrovato](https://community.gladysassistant.com/u/AlexTrovato)\
**Post date:** [October 9, 2021, 7:05am UTC](https://community.gladysassistant.com/t/un-cdn-pour-les-assets-statiques-du-forum/6569/15 "2021-10-09T07:05:18Z")

</div>

haha it’s not me who works!! 😛

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [October 9, 2021, 7:07am UTC](https://community.gladysassistant.com/t/un-cdn-pour-les-assets-statiques-du-forum/6569/16 "2021-10-09T07:07:21Z")

</div>

25% of the re-generation!

![Screenshot 2021-10-09 at 15.06.58](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/9/936cdf46fa58ce8e9de814e326d32e07559ca664.png)

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [October 9, 2021, 7:19am UTC](https://community.gladysassistant.com/t/un-cdn-pour-les-assets-statiques-du-forum/6569/17 "2021-10-09T07:19:19Z")

</div>

Good, but it actually creates a task per post on the forum in Sidekiq (the background task manager used by Discourse). Given that there are 49k posts on the forum, we will now need to process the queue 😂

It will take some time, but that’s just how it is 🙂 (and the queue is in «&nbsp;ultra low priority&nbsp;» so it doesn’t block normal forum execution)

 ![Screenshot 2021-10-09 at 15.16.37](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/1/14de18e2de05e551191055c24b57e4700aa92fa9.jpeg)

---

<div class="post-metadata">

**Author:** ![VonOx](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/vonox/32/10128_2.png) [@VonOx](https://community.gladysassistant.com/u/VonOx)\
**Post date:** [October 9, 2021, 10:56am UTC](https://community.gladysassistant.com/t/un-cdn-pour-les-assets-statiques-du-forum/6569/18 "2021-10-09T10:56:00Z")

</div>

OK, I understand system notifications on Discourse better

---

<div class="post-metadata">

**Author:** ![gaetanb76](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/gaetanb76/32/5911_2.png) [@gaetanb76](https://community.gladysassistant.com/u/gaetanb76)\
**Post date:** [October 9, 2021, 2:30pm UTC](https://community.gladysassistant.com/t/un-cdn-pour-les-assets-statiques-du-forum/6569/19 "2021-10-09T14:30:05Z")

</div>

Hello everyone,  
A long time ago, I made this request:

> [@Un accès à la documentation dans Gladys](https://community.gladysassistant.com/t/un-acces-a-la-documentation-dans-gladys/6166):
>
> J’avais déjà indiqué qu’un lien vers la documentation générale et d’autres vers la doc correspondante à l’intégration souhaitée ou à la création de scène seraient vraiment pratiques.

A link to the forum would also be interesting because indeed, we always go through a search engine to get there, Qwant for me.

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [October 10, 2021, 3:39am UTC](https://community.gladysassistant.com/t/un-cdn-pour-les-assets-statiques-du-forum/6569/20 "2021-10-10T03:39:53Z")

</div>

> [@gaetanb76](#):
>
> A long time ago, I made this request:

Good point, sorry I must have missed this request!

> [@gaetanb76](#):
>
> A link to the forum would also be interesting

But there is one!

 ![Screenshot 2021-10-10 at 11.38.33](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/0/0eda6cd5c6f4acae8f232366ad7e4f90dbcb5e44.png)

[Next page](https://community.gladysassistant.com/t/un-cdn-pour-les-assets-statiques-du-forum/6569.md?page=2)
