@PitaJ Cool! If the query string only changes on ./nodebb build
then "Cache everything" works well. I thought the query string was different for each user or represented some token/cookie. I guess I should have checked how it is generated before posting.
brandt
Posts
-
NodeBB + Cloudflare Caching -
NodeBB + Cloudflare CachingNodeBB's Documentation contains some instructions on how Nginx can be modified in order to scale NodeBB:
location @nodebb { proxy_pass http://127.0.0.1:4567; } location ~ ^/assets/(.*) { root /path/to/nodebb/; try_files /build/public/$1 /public/$1 @nodebb; } location /plugins/ { root /path/to/nodebb/build/public/; try_files $uri @nodebb; }
If I understand it correctly, static resources will be served faster this way.
I wanted to apply the same logic to Cloudflare caching. Are there instructions anywhere on how to do this properly? For now, I've created 2 Page Rules:
- /plugins/* - Cache Level: Cache everything
- /assets/* - Cache Level: Cache everything
The problem with this "Cache everything" setting is that query strings are not ignored. So these 2 requests take 2 keys in the cache, even though it's the same document:
GET /assets/src/modules/composer/tags.js?v=17etv7hm589 127.0.0.1
GET /assets/src/modules/composer/tags.js?v=23etv7hm589 127.0.0.1
If I use "Ignore query string", then the request below isn't cached because Cloudflare doesn't cache *.json files by default (only if you use the "Cache everything"):
GET /assets/src/modules/composer/tags.js?v=17etv7hm589 127.0.0.1
It seems that it's possible to cache everything while ignoring query strings, but only on Enterprise plans. I'm currently using the Pro plan.
Anyways, if anyone has any tips on how to optimize NodeBB with Cloudflare, I'd appreciate it.