How to Clear the Cache in VS Code

Clearing the caches in VS Code is an effective way to troubleshoot and resolve performance issues like extension errors or unexpected behavior. Here’s how.  

Written by Edgar Gulay
Published on Jan. 10, 2025
Developer clearing cache with trash icon
Image: Shutterstock / Built In
Brand Studio Logo

Visual Studio Code (VS Code) is a popular and versatile code editor beloved by developers worldwide. However, like any software, it can encounter performance issues, extension errors or unexpected behavior.

7 Ways to Clear VS Code Cache

  1. Clearing the extension cache.
  2. Clearing the workspace storage.
  3. Clearing user data cache.
  4. Clearing editor cache.
  5. Clearing extension host cache.
  6. Clearing node modules cache for extension developers.
  7. Restart VS code.

I wasted an hour fixing an issue that could’ve been solved by just clearing cache and removing a few lines in settings.json.

One effective way to troubleshoot these problems is to clear the various caches that VS Code uses. In this blog post, I’ll guide you through the process of clearing different types of caches in VS Code to help you maintain a smooth and efficient coding environment.

 

7 Ways to Clear VS Code Caches

1. Clearing Extension Cache

Extensions are a crucial part of the VS Code ecosystem, adding functionality and enhancing productivity. However, they can sometimes cause issues or conflicts. Here’s how to clear the extension cache:

  1. Uninstall Extensions: Open the Extensions view by pressing Ctrl+Shift+X (or Cmd+Shift+X on macOS). Right-click on the extension you want to remove and select “Uninstall.”
  2. Reinstall Extensions: After uninstalling, you can reinstall the necessary extensions from the extensions view.

More on Software EngineeringWhat Is an Integrated Development Environment (IDE)?

2. Clearing Workspace Storage

Workspace storage holds various data related to your workspace, which can accumulate and cause issues over time. Here’s how to clear its cache:

  1. Open command palette: Press Ctrl+Shift+P (or Cmd+Shift+P on macOS).
  2. Search for Developer: Open Workspace Storage: This will open the folder where workspace storage files are kept.
  3. Delete workspace storage files: In the opened folder, delete all the files and folders to clear the workspace storage.

3. Clearing User Data Cache

User data includes settings, snippets, keybindings and more. Resetting user data can resolve various problems.

1. Navigate to the User Data Folder:

  • Windows: C:\Users\\AppData\Roaming\Code\User
  • macOS: /Users//Library/Application Support/Code/User
  • Linux: ~/.config/Code/User

2. Delete Specific Files

You can delete specific files like settings.json, keybindings.json, etc., or delete the entire user folder to reset all user data. Or you can remove targeted lines to avoid much more chaos.

4. Clearing the Editor Cache

Clearing the editor cache can help if you’re experiencing issues related to the editor itself.

Clear Temporary Files

  • Windows: Use Disk Cleanup or manually delete files in C:\Users\\AppData\Local\Temp
  • macOS: Clear cache in /private/var/folders
  • Linux: Clear cache in /tmp

5. Clearing Extension Host Cache

If you’re still facing issues, clearing the extension host cache might be necessary.

1. Navigate to the Extension Host Cache Folder

  • Windows: C:\Users\\AppData\Roaming\Code\CachedData
  • macOS: /Users//Library/Application Support/Code/CachedData
  • Linux: ~/.config/Code/CachedData

2. Delete Cache Data

Delete all the contents of the CachedData folder.

6. Clearing Node Modules Cache for Extension Developers

If you’re developing extensions or using Node.js within VS Code, clearing the Node modules cache can be helpful.

  1. Delete node_modules Folder: Navigate to your project directory and delete the node_modules folder.
  2. Clear npm Cache: Run npm cache clean --force in the terminal.

7. Restart VS Code

After clearing the caches, restart VS Code to apply the changes.

A tutorial on how to clear caches in VS Code. | Video: Jie Jenn

More on Software EngineeringZsh: Command Not Found: Brew Error Solved

 

Additional Tips to Clear VS Code Cache

  • Backup Settings: Before clearing caches, back up your settings, keybindings, snippets and other configurations.
  • Update VS Code: Ensure you’re using the latest version of VS Code, as updates often resolve existing issues.

Frequently Asked Questions

Clearing the cache in VS Code is a useful way to troubleshoot common issues like slowed performance, extension errors and unexpected behavior. It can help users maintain a smooth and efficient coding environment.

  1. Uninstall Extensions: Press Ctrl+Shift+X (or Cmd+Shift+X on macOS) to open the extension view. Right-click on the extension you want to remove, and select “Uninstall.”
  2. Reinstall Extensions: After uninstalling, you can reinstall the necessary extensions from the extensions view.
Explore Job Matches.