16 Jan 2021

Overcoming bandwidth limitations on Prismic

While we do not have a "one-size-fits-all" CMS solutions that we always use, we've repeatedly used Prismic for different projects of all sizes, and it still hasn't fallen short except for one thing: the bandwidth limitation on their CDN. Even at the highest plan, they still cap the bandwidth usage at 1TB max, as you read up on here.

This limit is probably fine for most projects, but in certain cases you might find yourself close to hitting it if the website you are launching contains heavy assets (like videos or downloadable assets) and expects heavy traffic. We had such potential situation when launching NEOH. Since the brand was entering a new market, had strong deals with distributors and was airing commercials on TV, we could expect some heavy traffic on the website, so we decided to play it safe and put mechanisms in place to avoid getting close to the bandwidth limit – which would also reduce costs by not having to go with the highest plan on Prismic. The solution, at the end, turned out to be pretty easy: 2 CDNs.

Nobody tells you you can't use another CDN chained in front of the Prismic CMS – so that's basically what we did, and it turned out to be pretty simple. Summarising the whole process in short, and without getting too much into technical details:

  1. We configured a CDN that had Prismic's CDN as origin, with different URL rules based on the type of asset. You can see them by just checking their content API responses.
  2. We modified our website logic to replace all URLs from Prismic's CDN to point to our CDN.
  3. The website delivers these URLs to the client, so clients never actually request any assets from Prismic but instead from our own CDNs.

Configuring a solution like this is a piece of cake in providers like AWS: it was done in a matter of minutes and it removed all the bandwidth issues for good, with minimal changes in the code base.

If you use Apache:

And voila! Error most likely solved. If this still does not solve the error, there might be one more thing left to do: ensure that your CDN is configured to forward headers from/to your client and origin.

Oh, we are also constantly looking for mid-level & senior devs to join our team – holla at us:

Next

The Gang in Vienna | Offsite 2023 01