Feature request: Cache cleanup
- Dominant language
- TypeScript
- Stars
- 2.9k
- Forks
- 267
- Avg merge
- 1d 25m
- Merged PRs (30d)
- 14
Description
### Describe the feature
As a regular CDK user, the `~/Library/Caches/com.amazonaws.jsii` dir on my Mac (aka [defaultCacheRoot](https://github.com/aws/jsii/blob/08576aa034c2cd8d2972428e8030d8ec44786e05/packages/%40jsii/kernel/src/tar-cache/default-cache-root.ts#L9-L15)) has steadily grown. It currently stands at over 13GB, mostly made up of old versions of CDK dependencies.
I'd like to request some mechanism for preventing this cache from growing indefinitely.
### Use Case
I should be able to use CDK without having to worry about gradually running out of disk space.
### Proposed Solution
Two options, which are not mutually exclusive:
1. Add a documented "clear cache" command to the CDK CLI that would allow users to clear the contents of the JSII cache directory (and possibly other caches as well; my `~/Library/Caches/aws-cdk-lib` and `~/Library/Caches/@aws-cdk` stand at a total of 3GB).
2. Add a system for automatically removing items from the cache that have not been used in a certain amount of time (say, 30 days). For example, on each run JSII could `touch` files that it reads from the cache, then delete all files in the cache whose `mtime` is over the time limit.
### Other Information
_No response_
### Acknowledgements
- [ ] I may be able to implement this feature request
- [ ] This feature might incur a breaking change
### CDK version used
2.178.2
### Environment details (OS name and version, etc.)
macOS 15.3.1
Contributor guide
Research direction
Start by reading packages/@jsii/kernel/src/tar-cache/default-cache-root.ts and trace how the JSII cache is read and populated. Determine whether the intended outcome is a documented CDK CLI clear-cache command, automatic expiry, or both; done means the selected cache-management behavior prevents indefinite growth and is documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cli, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100