Generic Origin Mode

Cachely has built-in support for Prismic, Contentful, Sanity, Shopify, Cloudinary, and Imgix, but you can also proxy any HTTPS asset origin by providing a custom origin URL in your tenant configuration.


Use cases

  • AWS S3 — Proxy assets from S3 buckets without exposing bucket URLs
  • Cloudflare R2 — Add caching and bandwidth tracking on top of R2
  • Google Cloud Storage — Route GCS-hosted media through Cachely
  • Legacy CMS servers — Proxy assets from self-hosted CMS installations
  • Any HTTPS origin — If it serves files over HTTPS, Cachely can proxy it

Tenant configuration

Select Generic Origin as the CMS type when creating or editing a tenant in the admin dashboard. Enter the full HTTPS origin URL in the Origin URL field. If your videos are hosted on a separate origin, fill in the optional Video Origin URL field.

You can also create generic origin tenants via the API by sending the origin URL as the originUrl field:

Example: S3 bucket

{
  "slug": "my-project",
  "cms": "generic",
  "originUrl": "https://my-bucket.s3.amazonaws.com",
  "websiteDomain": "my-site.com",
  "cacheTTL": 86400
}

With this configuration, a request to:

https://my-project.cachely.io/images/photo.jpg

Is proxied to:

https://my-bucket.s3.amazonaws.com/images/photo.jpg

Example: Cloudflare R2

{
  "slug": "my-r2",
  "cms": "generic",
  "originUrl": "https://pub-abc123.r2.dev",
  "cacheTTL": 604800
}

Example: Google Cloud Storage

{
  "slug": "my-gcs",
  "cms": "generic",
  "originUrl": "https://storage.googleapis.com/my-bucket",
  "cacheTTL": 172800
}

Separate video origin

If your videos are served from a different origin than images, you can configure a videoOrigin. In the admin dashboard, this field appears when Generic Origin is selected as the CMS type.

Via the API:

{
  "slug": "my-project",
  "cms": "generic",
  "originUrl": "https://images.my-cdn.com",
  "videoOrigin": "https://videos.my-cdn.com",
  "cacheTTL": 86400
}

Video file types (mp4, webm, mov, m4v) will be fetched from videoOrigin, while all other asset types use the primary origin.


Configurable options

Each tenant supports these configuration options:

OptionTypeDefaultDescription
originstringPrimary HTTPS origin URL (required)
videoOriginstringSeparate origin for video files
cacheTTLnumber172800 (2 days)Edge cache duration in seconds (60 – 2,592,000)
allowedTypesstring[]— (all types allowed)Content-Types to allow. If not set, all types are served
stripQueryParamsForstring[]— (query params included in cache key)File extensions where query params are stripped from cache key
blockedBotsRegexstring(default pattern)Custom regex for blocking bots by User-Agent
websiteDomainstringYour frontend domain, sent as Referer to origin

Cachely SDK with generic origins

Use the Cachely SDK and createGenericProvider to plug any HTTPS origin into the SDK:

import { createGenericProvider, createCachelyFetch } from '@cachely-io/sdk'

const myOrigin = createGenericProvider({
  id: 'my-origin',
  apiHosts: [],                                  // none if you only proxy assets
  assetHosts: ['my-bucket.s3.amazonaws.com'],    // your origin host(s)
})

const cachelyFetch = createCachelyFetch({
  tenant: 'my-project',
  provider: myOrigin,
})

// Use as a drop-in fetch — asset URLs are rewritten automatically

URLs like https://my-bucket.s3.amazonaws.com/images/photo.jpg are rewritten to https://my-project.cachely.io/images/photo.jpg, preserving the path and query parameters.


Notes

  • The origin must be HTTPS. HTTP origins are rejected.
  • The path structure is preserved 1:1 — the request path is appended directly to the origin URL.
Need help understanding this?Ask Cachely Copilot about features, setup, or integrations.
Ask Copilot →