Cloudflare Enablement
R2
Testing
Edit this page on GitHub
Set theme to dark (⇧+D)

Object lifecycles

Object lifecycles affect how long objects uploaded to your bucket are kept.

For example, you can create an object lifecycle rule to delete objects after 30 days, or you can set a rule to abort multipart uploads after 30 days.

​​ Behavior

  • Objects will typically be removed from a bucket within 24 hours of the x-amz-expiration value.
  • When a new lifecycle policy is applied, newly uploaded objects’ x-amz-expiration value immediately reflects the expiration based on the new rules, but existing objects may experience a delay. Most objects will be transitioned within 24 hours but may take longer depending on the number of objects in the bucket. While objects are being migrated, you may see old applied rules from the previous policy.
  • An object is no longer billable once it has been deleted.
  • Buckets have a default lifecycle policy to expire multipart uploads seven days after initiation.

​​ Add an object lifecycle rule from the Cloudflare dashboard

  1. From the Cloudflare dashboard, select R2.
  2. Locate and select your bucket from the list.
  3. From the bucket page, select Settings.
  4. Under Object lifecycle rules, select Add rule.
  5. Fill out the fields for the new rule.
  6. When you are done, select Add rule.

​​ Configure a bucket’s lifecycle policy

When you create an object lifecycle rule, you can specify which prefix you would like it to apply to.

Below is an example of configuring a lifecycle policy with different sets of rules for different potential use cases.

​​ Get a bucket’s lifecycle policy

​​ Delete a bucket’s lifecycle policy