Bandwidth Usage During Development

Hi Dato Team & Community,

I hope youā€™re doing well!

Iā€™ve noticed that while developing and refreshing my local site, a significant portion of my clientā€™s bandwidth is being consumed. Iā€™m concerned about exceeding the bandwidth allocation during development and testing phases.

Is there a recommended approach or workaround to minimize bandwidth usage while in development? For instance:

  • Does DatoCMS offer caching options or local APIs to reduce requests?
  • Is there a way to use a local copy of content for development purposes instead of continuously querying the live API?

Iā€™d appreciate any guidance or best practices you can share!

Thank you in advance for your help

Hi @deven,

Welcome to the forum!

Is there a particular project youā€™re thinking about? If you could please send me the project URL and the website frontend URL, I can take a deeper look for you? (You can either just post it in a reply, DM me here, or send an email to support@datocms.com and mention this thread). I took at look at the projects associated with your email but did not see one that was using a lot of bandwidth? Being able to see the specific project(s) youā€™re concerned about would let me better figure out what is using the bandwidth :slight_smile:

But, without knowing the specifics, here are some general concepts (and again, these are just generalā€¦ I donā€™t know if any of them apply to your project):

  • By far the largest consumer of bandwidth is customers accidentally serving MP4 videos as files (billed by the GB) instead of using Mux streaming (which get billed as streaming minutes). We have a guide about this: https://www.datocms.com/docs/streaming-videos/how-to-stream-videos-efficiently
  • For other filetypes, namely images, our automatic optimizations should significantly decrease bandwidth consumption, if enabled on your projects: https://www.datocms.com/docs/asset-api/asset-cdn-settings (in technical terms, this tells our image CDN Imgix to auto-serve the best image format available to any particular browser). You can further decrease filesize (at the expense of quality) by also setting the auto=compress param.
  • Hot module refresh (i.e. automatic reloads during development) can indeed incur many calls to our API, but that typically results in API calls and not bandwidth. Normally browser caching should keep the files in your local memory/disk cache?
  • We donā€™t offer ā€œlocal APIsā€ per se, but you can certainly cache our API responses on the frontend (and in many cases, it makes sense to do so). e.g. if youā€™re on Next, using the built-in fetch cache (for the app router) or incremental static regeneration (for the pages router) will help prevent re-fetching the same things from our APIs over and over again.
  • If your content is particularly large, you can also keep a local copy of your content (theyā€™re just JSONs) alongside your codebaseā€¦ but that is harder to manage and synchronize vs just using built-in fetch caching in your frontend.

Itā€™s hard to provide specific guidance without knowing the project and website youā€™re asking about specifically. Happy to take a deeper look there if you can share that, otherwise, I hope the above provide some good starting points?

I forgot to mention the obvious starting place, btw :person_facepalming::

Your Project Usages screen can help you break down the API call and bandwidth usages so you can better see what is causing it: https://www.datocms.com/docs/general-concepts/project-account-usages

Hey @roger

After investigating further, I found that the high bandwidth usage was caused by Vercel building my static site. Specifically, it seems to come from AstroImage downloading and resizing large images, which consumes a lot of bandwidth. Each build was consuming 350mb.

To address this, Iā€™ll be replacing AstroImage with the DatoCMS Astro Image component. This should transfer the bandwidth for image resizing and delivery from Vercel to the DatoCMS CDN, which should resolve the issue. If thatā€™s not enough, Iā€™ll tweak the Imgix and cache settings for local environment

Ty!

1 Like

Perfectā€¦ good catch, and thanks for the update!