How to cache assets


Speed up your site by caching your resources and reducing costly Object Storage Providers (OSP) bandwidth with Cassette (all without changing your source code).

Resources stored on popular OSP's like Amazon S3 and Google Cloud Storage aren't cacheable on Cloudflare if they are served directly from the OSP.

For example, if your img elements look similar to <img src='' />, you're site is slower and costs more than it should.

But don't worry, Cassette solves this problem by rewriting your OSP resources to fetch from a subdomain you control enabling Cloudflare to cache your assets.

Step 1
Configure and install Cassette

We used the following options to set up Cassette.

Install Options

Assets Subdomain
Object Storage Hostname

If your bucket has a path style URLs like, set the Object Storage Pathname install option to /my-bucket.

Step 2
Your Object Storage Providers resources should be cached after a couple requests!

Once installed, Cassette replaces references to Object Storage Hostname with Assets Subdomain.

Our website's source code contains an <img src='' />. Cassette enables Cloudflare to cache the image by swapping the hostname with before your browser loads the page.

Look for the CF-Cache-Status=HIT header in the image request to confirm its cached.