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.
Clear cache on Google Chrome
if(Test-Path -Path C:\Users\$username\AppData\Local\Google\Chrome\User` Data\Default\Cache)
Remove-Item -Path C:\Users\$username\AppData\Local\Google\Chrome\User` Data\Default\Cache -Recurse -Force
Write-host "Cache cleared"
Write-host "Specified path doesn't exist."
Provide the target username as an argument. If the cache has already been cleared, the error “Specified path doesn’t exist.” will be displayed.
del /q /s /f “C:\Users\<Username>\AppData\Local\Google\Chrome\User Data\Default\Cache”
<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.