Category filter

Script to clear browser cache on Windows devices

A browser cache is a database of files that stores resources such as texts, images, and other media from websites. This reduces the time required to load previously visited websites by avoiding the need to download the same data from the internet. However, browsers may load the previous version of websites even if the website is updated due to the cache present on the device. Also, caches can accumulate over time and consume storage space on the device. Hence, enterprises may require to clear the browser’s cache from the devices to save space and load newly updated websites without any issues. You can remotely deploy scripts from the Hexnode portal to clear the browser’s cache from the Windows devices.

Disclaimer:

The sample scripts provided below are adapted from third-party Open-Source sites.

Clear cache on Google Chrome

PowerShell script

Provide the target username as an argument. If the cache has already been cleared, the error “Specified path doesn’t exist.” will be displayed.

Batch script

Replace <Username> with the username of the user account from which the Google Chrome browser cache needs to be cleared. If the cache has already been cleared, executing the command may return an error.

Clear cache on Mozilla Firefox

PowerShell script

Batch script

Replace <Username> with the username of the user account from which the Firefox browser cache needs to be cleared. If the cache has already been cleared, executing the command may return an error.

Clear cache on Microsoft Edge

PowerShell script

The PowerShell scripts use the $username parameter to construct the path to the Chrome, Edge or Firefox cache folder, which includes the name of the user profile directory.
Get-ChildItem is used to fetch count of items in the cache directory before and after clearing the cache.

Notes:

  • Make sure the browser is closed before running the command.
  • It is recommended to manually validate the script execution on a system before executing the action in bulk.
  • Hexnode will not be responsible for any damage/loss to the system on the behaviour of the script.

  • Sample Script Repository