🚀 Meteor Scaling/Performance Best Practices

Two more tips for running Meteor apps behind Cloudflare:

  1. In Cloudflare Caching Settings, ensure you disable Always Online.

    If your Meteor app goes down or if there is a brief interruption to Internet connectivity between Cloudflare and the origin server, disabling Always Online will avoid a prolonged delay until Cloudlfare recognises that your Meteor app is online again.

  2. If you have enabled Content Security Policy (CSP) for your Meteor app, ensure that you add a Cloudflare Page Rule to bypass Cloudflare’s cache for the URL that accesses the Meteor runtime settings file meteor_runtime_config.js.

    This is how the page rule would look on the Cloudflare dashboard once configured:

    https://mymeteorapp.com/meteor_runtime_config.js
    Cache Level: Bypass

    If your Meteor app is located in a subfolder, then your page rule would look something like this:

    https://mymeteorapp.com/*/meteor_runtime_config.js
    Cache Level: Bypass

    If you don’t add this bypass rule, Cloudflare will automatically add a 14,400 second (4 hour) HTTP expires header for the meteor_runtime_config.js file.

    This will cause a problem when the time comes to update Meteor to a more recent version or make any other significant changes that affect Meteor’s runtime configuration settings. The user’s web browser will keep retrieving a stale cached version of meteor_runtime_config.js and go into a crazy reload loop.

    This is avoided by adding the above Cloudflare Page Rule which ensures that meteor_runtime_config.js is always served fresh.

13 Likes