Resolving bandwidth issues with image delivery via Google Drive

Published on Author mzabskyLeave a comment

Google Drive is an interesting alternative to professional CDNs when you need eg. an image gallery delivered to your end users. For a smaller scale application, it may well be able to deliver sufficiently significant amounts of data that would cost hundreds of dollars with a service like Amazon S3. It is however fairly easy to trip their “safeguards” which flag your application as “unfair” and randomly stop delivering some of the content you need delivered. This article discusses a simple workaround for at least some of these safeguards.

The use case I will be discussing here is delivering an image gallery of a hundred 200 KB images (20 MB total) that are displayed inline on your website.

Formally, Google Drive has no bandwith limitation, but they do have some form of (completely undocumented) bandwidth safeguards. These appear to come in three kinds:

  1. Per-user safeguard – I believe google does cut off IP addresses that are sources of massive amounts of traffic. The bandwidth required to trip this safeguard appears to be massive though (loading gigabytes of data across many thousands of files doesn’t trip it). This safeguard has historically caused some headaches for users with a shared IP internet connection.
  2. Per-file safeguard – There is also a safeguard that trips when there are way too many accesses to a single file. This safueguard too appears to be quite lenient, probably in order of tens of thousands of accesses per day.
  3. Per-referrer safeguard – Another safeguard trips when a single source directs way too much traffic to Google Drive. At least in my usage scenario, this safeguard appeared to be comparatively easy to trip (it started triggering once I had about 50 users per day accessing the gallery mentioned above).

When some of these safeguards trips, one of two things can happen:

  • The HTTP request gets redirected to a page with “temporarily unavailable” error message.
  • The HTTP request gets redirected to a page with a captcha test.

Either way, the image fails to load as an image.

Fortunately, the “per-referrer” safeguard is very easy to work around by simply telling your gallery page to not send the “Referrer” HTTP header. This can by achieved by putting following tag into the HEAD section of your page:

For me, adding this header fixed all the issues I had with Google Drive.

Leave a Reply

Your email address will not be published. Required fields are marked *