🤖 Cassette

The Skinny

Are you using Amazon S3, Google Cloud Storage, or some other object storage provider to serve your images and other assets? Cloudflare doesn't automatically cache these valuable resources! That's what Cassette is for.

Cassette 🐇 speeds up your site and 💰 saves you money on your object storage provider bill.

How to Install

Powered by Cloudflare

Cassette is powered by Cloudflare. If you're already using Cloudflare, click here to install Cassette.

TIP

Cloudflare offers DDoS protection, a global CDN, SSL certificates, and a lot more cool stuff for free. You should probably use it.

Configuration

Cassette only takes a few minutes to install on your site but additional required configuration is necessary for Cassette to work properly. The installation page covers the basics but we'll cover more here.

The following Options are available for each Object Storage Configuration:

Options

Assets Subdomain

This subdomain is created on your site by Cassette in order to enable Cloudflare to cache your object storage assets. Requests made to this subdomain are routed to Object Storage Origin.

PROTIP

This is necessary because Cloudflare can only cache assets on domains you control. For example, Cloudflare can cache assets.yoursite.com/image.png but not yoursite.s3.amazonaws.com/image.png.

Object Storage Origin

The URL of your Object Storage bucket obtained from your Object Storage Provider. This is probably something like yoursite.s3.amazonaws.com or https://yoursite.storage.googleapis.com. Requests made to your Assets Subdomain will be routed here.

INFO

The URL protocol defaults to http unless you provide one.

Object Storage Pathname
OPTIONAL

This option is useful if your Object Storage bucket has a pathname. Otherwise, ignore it. Some buckets are intialized with a path-style URL - like http://storage.googleapis.com/yoursite.

In this case, Object Storage Pathname would be /yoursite.

Additional Required Configuration

Once you've installed Cassette, there's one more thing you have to do. All the links on your website that point to Object Storage Origin should be changed to Asset Subdomain. Once you've updated your links, ensure Cassette is working by reloading the page and inspecting the cf-cache-status header on requests to Assets Subdomain.

EXAMPLE

Let's say your Assets Subdomain is assets.yoursite.com and your Object Storage Origin is yoursite.s3.amazonaws.com and your site contains a cute picture of your cat. The HTML for your cat picture probably looks something like <img src="https://yoursite.s3.amazonaws.com/mycat.jpg" />. This needs to be updated to <img src="https://assets.yoursite.com/mycat.jpg" />

Generally, any references to yoursite.s3.amazonaws.com should be updated to assets.yoursite.com.