Skip to content
daenhost
All technologies
Cloudflare R2 and resource delivery

Object storage and CDN

Store the file. Deliver the right version.

CSS, JavaScript, fonts and images kept away from the application origin, with versioned addresses, edge caching and device-appropriate images.

Two responsibilities, one coordinated delivery

Storage

R2: keep the objects

Files and their metadata form the published collection. Each address identifies a resource from one generation of the website.

Distribution

CDN: deliver the resources

The delivery network brings resources closer to visitors and reuses eligible responses while they remain valid.

Conceptual representation of these responsibilities. It does not show topology or live cache status.

A visit combines responses with different roles. HTML presents the content; CSS organizes the layout; scripts add behavior; fonts and images complete the visual identity. Those files recur across pages and visits, while the application response may need its own freshness policy.

Object storage and a CDN have complementary responsibilities: storage keeps the collection, the CDN organizes distribution. With that separation, public resources follow their own availability and freshness rules, and the application keeps its capacity for the processing that depends on it.

An object is more than the file contents

In object storage, each file is identified by a key inside a bucket. The visible path may resemble folders, but it functions as a name used to locate that object. Metadata accompanies the bytes and guides delivery: content type tells the browser how to interpret the response, while cache policy defines how it may be reused.

A file served with the wrong type remains a problem even when it is available: fonts, style sheets and images each need information compatible with their format. Publishing means checking the content and the response headers, at the address where the resource will be used.

Storage, edge and browser are separate layers

R2 keeps the published object. The CDN may retain a copy of the response at the edge. The browser may store another copy for later visits. Each layer has its own freshness conditions: a request can be answered by the browser, find the resource at the edge or need to retrieve it from storage.

A cache hit depends on response eligibility and the existence of a valid copy. Headers and rules define that result, checked through the address visitors actually use.

A sound policy distinguishes public files from responses that depend on access context. Reusing a stable resource can reduce transfers, while storing a personalized response requires careful evaluation of freshness and who may receive it. Correct content remains the primary requirement alongside performance.

The version is part of the address

Versioned resources distinguish old and new content through their addresses. An update can then be identified without waiting for every browser to discard its copy at the same time. This keeps content identity aligned with freshness across different delivery methods.

The principle is to keep the content behind each published address stable. This supports long cache lifetimes and the immutable directive for resources that will not be replaced at that path. Operations must honor the announced policy: overwriting an object with different bytes breaks the premise and may leave visitors using an old copy.

A page also needs consistency among its dependencies. Styles, scripts and images should match the presented content so an update does not combine incompatible elements. Versioning makes these differences explicit and keeps delivery predictable as the project evolves.

Each format needs its own treatment

CSS and JavaScript minification removes comments and whitespace without changing how the files behave. It reduces transferred bytes; oversized resources and unnecessary dependencies remain work for code review.

Fonts require attention to compatibility, file size and cross-origin permissions, where CORS defines what the browser accepts from another domain. Private content depends on its own authorization. Efficient delivery also avoids unused variants and repeated transfers of the same resource.

Raster images can be adapted in width, quality and format, while responsive markup helps the browser choose. Vector images have different characteristics and limits. Optimization needs to preserve proportion, transparency and compatibility: reducing bytes should not compromise visual identity or understanding.

Public distribution needs a clear boundary

Institutional styles, scripts, fonts and images are meant to reach visitors. Restricted documents, credentials and client data do not belong in this collection: a hard-to-guess name is not access control, which lives in authorization and delivery configuration.

The application also limits where it may load resources from through its Content Security Policy. That restriction complements browser protection without replacing the integrity of published files or storage administration. Public availability and permission to load a resource into a page are related but separate decisions.

Delivering files and recovering data have different goals

In progress

A cached copy can expire or be removed. A previous layout generation can roll website resources back, but it cannot recover the state of application data. These mechanisms support distribution and publishing; they do not form a backup policy by themselves.

Daen is still expanding its backup strategy. Public distribution and recovery are separate areas: adopting object storage for one does not show that the other is complete. Retention and restoration capability need to be evaluated according to the purpose of the data.

Key points

  • Separate responsibilities for object storage and distribution
  • Minification to reduce unnecessary delivery bytes
  • Versioned addresses supporting long cache lifetimes for immutable files
  • Fonts and images delivered separately from application execution
  • Responsive variants and edge transformations for raster images
  • Separation between public delivery, private data and backups

Sources

Related article

Which responses may be reused, by whom, for how long and how to confirm that the stored copy is still valid.

Caching with the right rules