User Agents

Web browsers and everyday web tech, explained

Clear Cache Using CMD: Step-by-Step Windows Guide

· 5 min read · Cookies and Cache

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Clearing your cache via the Command Prompt (CMD) allows you to remove temporary system files, flush DNS records, and reset network configurations without navigating through multiple GUI menus. This process is particularly useful for resolving internet connectivity issues, fixing website loading errors, and reclaiming disk space by purging stale temporary data that the system no longer requires.

What You'll Need

  • A computer running a version of Windows (10, 11, or older).
  • Administrative privileges (Administrator account) to execute system-level commands.
  • Basic knowledge of how to open the Start menu.

Step-by-Step

1. Open Command Prompt as Administrator

Most cache-clearing commands require elevated permissions to modify system files. If you run CMD as a standard user, you will receive an "Access Denied" error.

  1. Press the Windows Key on your keyboard.
  2. Type cmd into the search bar.
  3. Right-click on Command Prompt in the search results.
  4. Select Run as administrator.
  5. Click Yes when the User Account Control (UAC) prompt appears.

2. Flush the DNS Cache

The DNS (Domain Name System) cache stores the IP addresses of websites you have visited. If a website changes its IP address or the cache becomes corrupted, you may encounter "Page Not Found" errors.

  1. In the Command Prompt window, type the following command: ipconfig /flushdns
  2. Press Enter.
  3. You should see a confirmation message stating: "Successfully flushed the DNS Resolver Cache."

3. Clear the Windows Store Cache

If the Microsoft Store is lagging or apps are failing to update, clearing the store cache can reset the application's state.

  1. In the Command Prompt window, type: wsreset.exe
  2. Press Enter.
  3. A blank Command Prompt window will open. Do not close it; wait for the process to finish. The Microsoft Store app will automatically launch once the cache is cleared.

4. Purge Temporary System Files

Windows stores temporary files in specific folders that can accumulate over time. While you can do this via Disk Cleanup, CMD allows for a direct purge.

  1. To clear the user-level temporary files, type: del /q /f /s %temp%\*
  2. Press Enter. (The /q flag ensures quiet mode, /f forces deletion of read-only files, and /s deletes files from all subdirectories).
  3. To clear the system-level temporary files, type: del /q /f /s C:\Windows\Temp\*
  4. Press Enter.

5. Reset the Winsock Catalog

While not a traditional "cache," the Winsock catalog manages how network software accesses the network. Resetting it clears the socket cache and can fix deep-rooted connectivity issues.

  1. Type the following command: netsh winsock reset
  2. Press Enter.
  3. You will be prompted to restart your computer to complete the reset. Type shutdown /r /t 0 to restart immediately or restart manually via the Start menu.

Common Mistakes

  • Running without Admin rights: This is the most common error. If the prompt says "You do not have sufficient privileges," you must close the window and relaunch it using "Run as administrator."
  • Typing errors: CMD is literal. A missing space (e.g., typing ipconfig/flushdns instead of ipconfig /flushdns) will result in an "'ipconfig/flushdns' is not recognized" error.
  • Deleting active files: When clearing the %temp% folder, you may see messages saying a file cannot be deleted because it is "in use." This is normal; it simply means a program currently open is using that specific temporary file.
  • Closing the wsreset window: Closing the blank window during the wsreset.exe process can interrupt the cleanup and leave the store in an unstable state.

Tips

  • Create a Batch File: If you find yourself clearing these caches frequently, you can paste these commands into a Notepad file and save it as cleanup.bat. Running this file as an administrator will execute all commands in sequence.
  • Combine with Disk Cleanup: For a more thorough cleaning of the system cache (including Windows Update logs), run cleanmgr in CMD to launch the Disk Cleanup utility directly.
  • Check Connectivity First: If you are flushing DNS to fix a website issue, try pinging the site first using ping website.com to see if the server is actually reachable.

Troubleshooting

If the commands do not seem to work or you encounter errors, try the following solutions:

  • "Command not recognized": Ensure you have typed the command exactly as shown. Check for extra spaces at the end or missing slashes.
  • System File Corruption: If ipconfig or netsh commands fail consistently, your system files might be corrupted. Run sfc /scannow in the administrator CMD to repair corrupted Windows system files.
  • Permission Denied: Even as an administrator, some files in the C:\Windows\Temp folder are protected by the SYSTEM account. You can ignore these, as they are essential for the current OS session.
  • Network not restoring: If netsh winsock reset and ipconfig /flushdns do not restore internet access, the issue may be with your hardware (router/modem) or your ISP rather than a software cache.

Frequently Asked Questions

Will clearing the cache delete my personal files?

No. These commands target temporary system files, DNS records, and application caches. Your documents, photos, and installed software remain untouched.

Is it safe to run these commands regularly?

Yes, it is generally safe. Flushing the DNS and clearing temporary files is a standard maintenance practice. However, resetting Winsock should only be done when experiencing network issues, as it resets network adapter settings to default.

Why do some files refuse to be deleted in the Temp folder?

Windows cannot delete a file that is currently being used by an active program. If you want to clear more files, close all open applications and try the command again.

Does flushing DNS speed up my internet?

It does not increase your raw bandwidth speed, but it can make browsing feel faster by removing outdated or incorrect routing information that causes delays or errors when loading pages.

Can I use PowerShell instead of CMD?

Yes, most of these commands work in PowerShell. However, the syntax for deleting files (del) is slightly different in native PowerShell, though the CMD aliases usually function correctly.