Automate repository cleanup based on last download date

We’ve added a last_downloaded field to packages in Cloudsmith, extending search-based package retention rules to enable cleanup of unused packages.

This feature allows you to create retention rules that automatically clean up packages in your repository based on usage, rather than just age or count, ensuring you retain only actively used packages.

The new last_downloaded field is available for use in package queries when setting up or modifying retention rules via the Cloudsmith UI, API and Terraform provider. This field is also exposed in the API and UI, and can be used for general package search filtering.

Example query

If you want to set up a retention rule that automatically deletes packages older than a year, you can include the following package filter in your retention rule:

last_downloaded:<"now - 366 days"
Package filter query in Cloudsmith's retention rules feature

This functionality is not currently available for Docker images, but Docker support is planned for an upcoming release. Additionally, if a package is only proxied through Cloudsmith and never downloaded from the cache afterward, its total downloads will be 0, and the last_downloaded date will be null.

Keep up to date with our monthly product bulletin