Skip to content

Image CDN #344

@tom-sherman

Description

@tom-sherman

A CDN that can cache images in PDS's (eg. Avatars). This would remove our reliance on the bsky CDN and allow us to support images in our own lexicons.

We need to support revalidating images on demand (in the event of an avatar change), to enable long cache lifetimes (1 year would be good to aim for).

Also need eviction/blocking of images for moderation purposes.

We'll need to support simple size transformations, we need original and thumbnail (40x40) sizes for now.

Image path needs to include DID and the blob CID.

Flow is as follows:

  • User fetches /[did]/[cid]?size=[size]
  • If it's in the cache, return it (also set cache-control headers for client caching)
  • Otherwise fetch it from the PDS, stream to cache
  • Meanwhile apply any transforms
  • Apply our quality re-encoding and any limits (for storage reasons, a user might send us a 1GB image)
  • Return to the user the image, saving the transformed version in the cache if it's transformed alongside the original for future requests

We might be able to build this all on Vercel, but we should consider other options (Cloudflare & Bunny spring to mind)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions