Object lifecycles
Object lifecycles determine the retention period of objects uploaded to your bucket and allow you to specify when objects should transition from Standard storage to Infrequent Access storage.
For example, you can create an object lifecycle rule to delete objects after 90 days, or you can set a rule to transition objects to Infrequent Access storage after 30 days.
Behavior
- Objects will typically be removed from a bucket within 24 hours of the
x-amz-expiration
value. - When a lifecycle policy is applied that deletes objects, 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.
- When an object is transitioned from Standard storage to Infrequent Access storage, a Class A operation is incurred.
Configure your bucket’s object lifecycle policy
When you create an object lifecycle rule, you can specify which prefix you would like it to apply to.
- Note that object lifecycles currently has a 1000 rule maximum.
- Managing object lifecycles is a bucket-level action, and requires an API token with the
Workers R2 Storage Write
permission group.
Dashboard
- From the Cloudflare dashboard, select R2.
- Locate and select your bucket from the list.
- From the bucket page, select Settings.
- Under Object lifecycle rules, select Add rule.
- Fill out the fields for the new rule.
- When you are done, select Add rule.
S3 API
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
Dashboard
- From the Cloudflare dashboard, select R2.
- Locate and select your bucket from the list.
- From the bucket page, select Settings.
- Under Object lifecycle rules, select the rules you would like to delete.
- When you are done, select Delete rule(s).