When it comes to hosting, there will always be limitations, even if they aren’t advertised. There is no such thing as unlimited disk space or unlimited bandwidth. Certain hosts might market it this way, but then end up either suspending your account or charging overage fees. We don’t like this approach and make our plan limitations very clear here at Kinsta. Today we want to show you how to optimally offload PDF, DOCX, MP4, and MP3 hosting so that you don’t have to worry about it impacting your primary WordPress host. It can also help save you a significant amount of money by decreasing bandwidth and disk space.
Offloading Storage of PDF, DOCX, MP4, and MP3s
The first issue many sites with a large amount of PDF, DOCX, MP4, or MP3 files have is that they consume a lot of disk space. MP3 and MP4 files can’t always be compressed to smaller file sizes like when optimizing images. This can quickly consume your entire hosting plan and end up forcing you to upgrade. A typical MP3 file can be around 3 MB in size. While this might not sound like a lot, let’s say you have 1,000 MP3 files on your site. That right there alone is 3 GB. There are a lot of different ways to approach this, but we’ll share with you one that works great for our clients here at Kinsta.
Offload Storage to Amazon S3
You first need to offload the storage somewhere else so it isn’t consuming your origin server’s (WordPress host) disk space. One of the easiest ways to do this is to integrate with a service like Amazon S3. It is very similar to a web host, but generally, offers less expensive bandwidth and storage. Typically this is used for large sites that either need additional backups or are serving up large files (downloads, software, videos, games). Amazon has a proven track record of being very reliable, and because of their massive infrastructure, they are able to offer very low storage costs. Some of S3’s customers include Netflix, Airbnb, SmugMug, Nasdaq, etc.
Check out our in-depth integration guide for WordPress and Amazon S3. You can enable the option to remove the files from the local server once they have been offloaded to S3. This can help drastically reduce the disk space need with your WordPress host.
Amazon S3 – Remove files from local server
Offload Storage to Google Cloud Storage
You could also use this same approach with WordPress and Google Cloud Storage using the WP-Stateless plugin. They have an option to store and serve media files with Google Cloud Storage only.
WordPress Google Cloud Storage
Caching Delivery of PDF, DOCX, MP4, and MP3s on CDN
Another scenario you perhaps have is that you have enough disk space with your hosting provider, but your problem is simply high bandwidth consumption. In this case, you cand offload and cache the delivery of your PDF, DOCX, MP4, and MP3 files with a content delivery network (CDN). Read our in-depth post on why you should be using a WordPress CDN. You could also combine this following approach with the offloading storage option mentioned above.
WordPress hosts such as Kinsta also cache your content, but between updating your site and clearing the cache for development or testing purposes, caching on a CDN is usually more robust. Assets cached on a CDN are not meant to be purged frequently, that is how they can deliver your content faster. Caching on a CDN can help prevent traffic spikes from overwhelming your host and decrease your bandwidth costs. The last thing you want is for something to go viral and you’re left with a whopping bill.
We have seen that CDNs on average can offload up to 70% of the traffic. Follow the steps below on how to cache and deliver PDF, DOCX, MP4, and MP3 files on some recommended CDN providers.
How to Cache PDF, DOCX, MP4, and MP3s with KeyCDN
PDF and DOCX files are cached by all major CDN providers. However, some CDN providers don’t cache certain file types they might deem as dynamic content, such as .mp3 or .mp4. Typically CDNs are used for static content. However, KeyCDN is not one of those. Which means you don’t need to do anything special, other than setup KeyCDN on your WordPress site. Here are a few useful tutorials to get you started:
Below is an example of a mp3 on our development site. You can see that it is loading from KeyCDN (server: keycdn-engine) and the x-cache status shows a “HIT,” which means it is being delivered from the CDN cache. By delivering from your CDN provider’s cache you can ensure that it doesn’t use any bandwidth on your origin server (WordPress host).
Caching MP3 on CDN
How to Cache PDF, DOCX, MP4, and MP3s with Cloudflare
Cloudflare is another popular CDN provider with WordPress users, primarily because of their free plan and large network. Here are a few useful tutorials to get you started:
By default, they do cache PDF and DOCX files. However, to cache MP3 and MP4 files you have to configure page rules on your WordPress site.
Create Cloudfare Page Rule
To create a page rule login to Cloudflare and click on “Page Rules.” Then click on “Create Page Rule.”
Create Cloudflare page rule
They allow you to create dynamic patterns to match URL requests on your traffic. Below is an example of the syntax to create a page rule which would cache .mp3 files on Cloudflare.
Under the settings, you will want to select the “Cache Everything” option.
Cloudflare page rule to cache .mp3
Below is an example of a mp3 on our development site. You can see that it is loading from Cloudflare (server: cloudflare-nginx) and the cache status shows a “HIT,” which means it is being delivered from the CDN cache.
Cache MP3 on Cloudflare
Hopefully you know a little more about how to optimally offload PDF, DOCX, MP4 and MP3 hosting. Using storage solutions such as Amazon S3 and popular CDN providers can be a great way to reduce disk space, bandwidth, and save you money.