Jesse
11/03/2025, 3:34 PMMarvin
11/03/2025, 3:34 PMNate
11/03/2025, 3:37 PMNate
11/03/2025, 3:38 PMMarvin
11/03/2025, 3:38 PMpersist_result=True (or enabled via settings). You can set cache_expiration to influence reuse, but expired results are just treated as a cache miss on read—they are not removed from S3.
- If you want time-based deletion, configure an AWS S3 Lifecycle Policy on the bucket/prefix where Prefect writes results.
- Deleting/retaining flow runs in Prefect Cloud does not affect S3 objects.
Example (won’t delete S3 after 7 days—just stops reusing it):
from datetime import timedelta
from prefect import task, flow
@task(persist_result=True, cache_expiration=timedelta(days=7))
def compute():
return "hello"
@flow
def my_flow():
return compute()
if __name__ == "__main__":
my_flow()
Docs for deeper reading:
- Results and persistence: Prefect 3 results
- Caching and expiration semantics: Caching concepts and Advanced caching
- Flow run/DB retention (separate from S3): Database maintenance
If helpful, I can suggest a storage key prefix strategy and an S3 lifecycle rule to auto-expire results after your desired window. Would you like that?Nate
11/03/2025, 3:38 PMJesse
11/04/2025, 5:58 PMJesse
11/04/2025, 5:58 PMNate
11/04/2025, 6:19 PMWell, mostly hopingas in, ideally we'd clear out your old blob stuff?
Jesse
11/05/2025, 10:51 AMJesse
11/05/2025, 10:52 AMJesse
11/05/2025, 10:53 AM