NodeBB + Cloudflare Caching

Technical Support
  • #1

    NodeBB's Documentation contains some instructions on how Nginx can be modified in order to scale NodeBB:

    location @nodebb {
    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
    GET /assets/src/modules/composer/tags.js?v=23etv7hm589

    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

    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.

  • Global Moderator Plugin & Theme Dev

    @brandt said in NodeBB + Cloudflare Caching:

    The problem with this "Cache everything" setting is that query strings are not ignored.

    Is this really a problem? The query string only changes when you run ./nodebb build, so generally you should only have a single one.

  • #3

    @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.

Suggested Topics

  • 1 Votes
    8 Posts

  • 0 Votes
    6 Posts

  • 0 Votes
    1 Posts

  • 0 Votes
    15 Posts

  • 1 Votes
    4 Posts

| | | |