DEV Community

Cover image for Clearing the Cache in Visual Studio Code
Eddie Gulay
Eddie Gulay

Posted on • Edited on

Clearing the Cache in Visual Studio Code

A Comprehensive Guide

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.

I spent about an hour fixing up something that could've been done by just clearing cache and removing 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, we’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.

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:

Steps

  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.

2. Clearing Workspace Storage

Workspace storage holds various data related to your workspace, which can accumulate and cause issues over time.

Steps

  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.

Steps

  1. Navigate to the User Data Folder:
    • Windows: C:\Users\<YourUsername>\AppData\Roaming\Code\User
    • macOS: /Users/<YourUsername>/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 just remove targeted lines to avoid much more chaos.

4. Clearing Editor Cache

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

Steps

  1. Clear Temporary Files:
    • Windows: Use Disk Cleanup or manually delete files in C:\Users\<YourUsername>\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.

Steps

  1. Navigate to the Extension Host Cache Folder:
    • Windows: C:\Users\<YourUsername>\AppData\Roaming\Code\CachedData
    • macOS: /Users/<YourUsername>/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.

Steps

  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.

Additional Tips

  • 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.

You might be interested

Check out OctoPalm.js a light weight library to add realtime search in your website with ease OctoPalm js 🔎


if you're wondering what happened for me to end up here check github.com/eddiegulay

Top comments (0)