So what’s the need for this?

The WordPress core size is relatively small. You add a theme and a couple of plugins, and it’s still relatively small. And when a new site is launched, the size of a site is fairly small to host. The issue starts to arise when your uploads directory starts to grow – this is where all items uploaded through the WordPress media library reside.

For every image you upload to the Media Library, WordPress creates a couple different versions of that image, depending on your specific setup. The default sizes are:

  • Thumbnail
  • Medium
  • Medium Large
  • Large

This is on top of the original, ‘full-size’ image. And if you, a plugin or your theme adds more sizes, then there’s even more copies made. As time goes by and you continue to upload images, the upload folder size starts to grow quite a bit.

For a setup that includes backups of your site, like the WordPress Support Package, these backups start to take longer and longer to process as there’s more images to backup. Also, when it comes to copying a site, maybe for our support team to work on it locally, the time it takes to download a backup will go up as well, which means we spend more time trying to replicate a website.

A solution that we’ve decided on is to offload the uploads directory to Digital Ocean Spaces. Digital Ocean provide many services, such as server hosting, database hosting and storage hosting. What we’re interested in is the storage hosting they offer, specially their S3-compatible object storage with a built-in CDN. In simple terms, this is an option for hosting files, such as images, from a separate location from the server that the site is hosted on. They provide a built-in CDN to improve the speed of delivery of assets, so files are cached and served from a location closer to the user who visits your site, wherever they are in the world.

How’s it done?

This is where the DigitalOcean Spaces Sync plugin comes in. This provides the necessary link between WordPress and Digital Ocean Spaces, automatically moving uploaded files to Spaces. For an existing WordPress site, you’ll need to move the existing files first and run a MySQL query to update the database URLs that point to the existing /wp-content/uploads folder. The best way we found to move files was to use rclone, although you could move the files using FTP, if that’s easier for you.

The images on this site are all coming from Spaces. Specifically, we bought https://wibble.space and we’re using subdomains for each Space that we need. Then each site has a folder in the space, such as /wearewibble-com/ to keep everything organised.

For this site, the uploads folder was over 300MB. This is fairly small compared so the sites we host, which have uploads folders that total over 20GB. And that’s always growing. By moving the uploads folder, we can now backup sites faster and download backups faster for replication. This frees up the servers to focus on handling requests for other resources, leaving the images for Spaces to serve, all from a lightning quick CDN.

Another reason for trying to reduce the size of all of our website apps is in the event of disaster recovery. Should a site become completely unusable and a backup of the site is required, it will greatly reduce the time needed to package up our latest backup and transfer it to us, using our in-house back up and recovery system. This could save hours to get a site back up and running, should the worse case scenario occur.

We encountered a problem..

While writing this blog and applying this setup to more sites, we came across some limitations of the DO Spaces Sync plugin, and we are now transitioning to using the WP Offload Media Lite plugin by Delicious Brains.

There’s a couple reasons for this. The DO Spaces Sync plugin didn’t correctly handle uploads with the same file name, which could cause issues if a user was to mistakenly upload a second image with the same file name. Another issue was that it didn’t support regenerating thumbnails. This comes up sometimes when you’re either building a new site, or maybe if you’re adding more features to an existing build and this requires a new image.

On the other hand, WP Offload Media Lite didn’t have issues with image upload naming, and actually specifically mentioned supported for regenerating thumbnails, either through WP-CLI commands or through the Regenerate Thumbnails plugin.

Who requested this feature?

Nobody did! In Wibble, we are constantly trying to improve our set up and provide a better service to our clients. So, with that in mind we are rolling this feature out to all sites on the Wibble Support Package for no additional cost, as we constantly upgrade the offering to all our clients!