Cache Cleaning Cheat Sheet

Cache Cleaning Cheat Sheet

M. Zakyuddin Munziri

M. Zakyuddin Munziri

@zakiego

Originally written in Bahasa Indonesia.

Background

I really enjoy cleaning cache. It's satisfying to free up storage and ensure my development environment is as clean and efficient as possible. Over time, I've collected commands and tools to make it easier to manage and clear cache for various package managers.

Note

Please note that you should check each command before running it and proceed at your own risk. Clearing cache can sometimes cause unexpected issues or the need to re-download packages and rebuild projects.

Despite these potential drawbacks, keeping cache clean helps maintain an efficient and organized workspace, ensuring that old or corrupted files don't interfere with development.

Cheat sheet

PNPM

pnpm store prune

Ref: https://github.com/orgs/pnpm/discussions/4413


NPM

npm cache clean --force

Ref: https://www.warp.dev/terminus/clear-npm-cache


Yarn

yarn cache clean

Ref: https://yarnpkg.com/cli/cache/clean


Bun

bun pm cache rm

Ref: https://bun.sh/docs/cli/pm


Node Modules

This tool allows you to list any聽node_modules聽directories in your system, as well as the space they take up. You can then select which ones you want to erase to free up space. Yay!

npkill

Ref: https://www.npmjs.com/package/npkill


Docker

Everything

docker system prune -a

# WARNING! This will remove:
#  - all stopped containers
#  - all networks not used by at least one container
#  - all images without at least one container associated to them
#  - all build cache
#
# Are you sure you want to continue? [y/N]

Container

docker container prune

# WARNING! This will remove all stopped containers.
# Are you sure you want to continue? [y/N]

Image

docker image prune -a

# WARNING! This will remove all dangling images.
# Are you sure you want to continue? [y/N]

The -a flag removes all unused images, not just the dangling ones.

Volume

docker volume prune

# WARNING! This will remove anonymous local volumes not used by at least one container.
# Are you sure you want to continue? [y/N]

Build Cache

docker buildx prune

# WARNING! This will remove all dangling build cache.
# Are you sure you want to continue? [y/N]

Network

docker network prune

# WARNING! This will remove all custom networks not used by at least one container.
# Are you sure you want to continue? [y/N]

Ref:


NVM (Node Version Manager)

nvm cache clear

Ref: https://github.com/nvm-sh/nvm?tab=readme-ov-file


Next.js

Delete the .next folder

This command was created using ChatGPT. Do with your own risk!

find . -type d -name ".next" -exec rm -rf {} +

Biome.js

Delete this folder:

  • Linux:聽~/.cache/biome;
  • Windows:聽C:\Users\<UserName>\AppData\Local\biomejs\biome\cache
  • macOS:聽/Users/<UserName>/Library/Caches/dev.biomejs.biome

Ref: https://biomejs.dev/guides/integrate-in-editor/#daemon-logs

More Articles

I Stopped Digging Through Logs

I Stopped Digging Through Logs

Debugging changed when I stopped reading logs manually and started using AI agents to correlate errors across observability data - faster root cause, fewer dead ends.

Speed Was Never the Hard Part in CI CD

Speed Was Never the Hard Part in CI CD

Fast pipelines don't eliminate shipping fear. Confidence comes from safe rollbacks, feature flags, and systems that behave predictably when things go wrong.