Photo by Curology on Unsplash

Where should your web app images be hosted?

Posted: 05 Jun 2022. Last modified on 05-Jun-22.

This article will take about 3 minutes to read.


You’ve done it - you’ve finalized the architecture for your content focused app, and are about to start including real data. As you generate your first large image files, you are suddenly forced with a decision.

Where should these large files live?

Considering git

Though hosting images in a git repo is an option, it’s not a very good solution. Git is meant to be used on text files, and other line-based file formats. Image formats like PNG or JPG aren’t based on lines, so if there is a change in the file, we might end up duplicating the whole file in each diff. Bad Juju.

For this reason, it’s better to only store small icon files in git, which are critical to its ability to function (eg, a “close” icon). Any non-critical media should be stored externally.

Considering a Content Management System

A Content Management System (CMS) is usually a good solution for a couple of different reasons.

But those features come at a cost. You will need to have an account with a CMS provider, who will likely charge a subscription fee, a per-access fee, or both. There are more things to consider as well, which I’ll go into below.

Ensure scalability

You will also need to consider how easy it is to scale. If the CMS is only able to handle a couple hundred simultaneous downloads per account before you get rate limited, it might not be a good solution.

Ensure migration is possible

Finally, you should consider how much lock in you will be commiting to by using the CMS. If the CMS provider were to go out of business, or have a data loss incident, how big of a problem would that be for you?

You should be backing up your content, and making sure that your CMS integration code is isolated from the rest of your codebase, and that all requests get forwarded through an Adapter. That way, if you do need to switch providers, you will reduce the amount of code that you need to modify.

Considering a Storage Bucket

This is the solution that a lot of developers end up using, because it is straightforward. Essentially, this involves putting your images into cloud storage, so that they can be retrieved directly.

There are a bunch of providers for this, which range from managed, photo-specific storage such as:

to unmanaged, blob storage that allows you to store any kind of file, like:

All of these are decent options, which allow for you to choose the level of effort you’d like to commit to.

Make sure that you know all of the associated fees before getting too entrenched in any of these options. Some platforms have more lock-in than others, which might force you to pay more than you expect to later on.

Conclusion

It’s good to consider all of the options before committing to a major architectural decision. Make sure that the solution that you choose will support your needs well into the future.