Clear Cache Using CMD: Step-by-Step Windows Guide
In this article
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.
- Press the Windows Key on your keyboard.
- Type
cmdinto the search bar. - Right-click on Command Prompt in the search results.
- Select Run as administrator.
- 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.
- In the Command Prompt window, type the following command:
ipconfig /flushdns - Press Enter.
- 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.
- In the Command Prompt window, type:
wsreset.exe - Press Enter.
- 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.
- To clear the user-level temporary files, type:
del /q /f /s %temp%\* - Press Enter. (The
/qflag ensures quiet mode,/fforces deletion of read-only files, and/sdeletes files from all subdirectories). - To clear the system-level temporary files, type:
del /q /f /s C:\Windows\Temp\* - 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.
- Type the following command:
netsh winsock reset - Press Enter.
- You will be prompted to restart your computer to complete the reset. Type
shutdown /r /t 0to 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/flushdnsinstead ofipconfig /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.exeprocess 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
cleanmgrin 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.comto 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
ipconfigornetshcommands fail consistently, your system files might be corrupted. Runsfc /scannowin the administrator CMD to repair corrupted Windows system files. - Permission Denied: Even as an administrator, some files in the
C:\Windows\Tempfolder 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 resetandipconfig /flushdnsdo 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.