Table of Contents
- What is Package Cache?
- Location of Package Cache Folder
- Why Package Cache?
- How Package Cache Works?
- What if I remove those files and folders?
- Are they temporary files?
- How to change the location of Package Cache files?
- How to disable the package cache?
- Does Microsoft recommend deleting Package Cache files?
- What is the importance of Caching?
- When should I clear the package cache stored by Visual Studio?
- When to move the package Cache?
- What happens if you change the CachePath registry policy?
- How often should I delete Package Cache?
What is Package Cache?
Package Cache is a system folder located on the drive where your operating system was installed. This is a global folder used by applications to store settings, caches, installers, and packages. Visual Studio is one such application that stores a large portion of its data in the Package Cache. There is no need for authentication to access these folders.
Most people consider it a bug, but these files are no bugs or errors in the applications.
Location of Package Cache Folder
The location of Package Cache folders varies from OS to OS and even from application to application. In the case of Windows, it is recommended to store those application-dependent packages, and settings files in the Package Cache folder, which is located as follows:
In this location, you will find plenty of subfolders related to application settings, caches, and installers of the applications. These folders are usually in an unknown hash format, and when you open them, you'll find a zip file and other unreadable files. These files can only be accessed by the application that created them.
These are the files and folders whose size is in Gigabytes.
Why Package Cache?
When you install applications such as Visual Studio, MS SQL Server Management Studio, Camtasia, and others, they reserve some space in the System Partition for their own needs, and the Things folder is located inside Program data and they are generally hidden from the user by default so that the user does not accidentally modify it.
You cannot change the location of Package Cache during installation, and by default, most applications store in Package Cache and then use those files in the background without giving the user any clew, and they do not require any authentication to access as they used to require for accessing other files.
If you want to uninstall, repair, or update/upgrade an existing application on your computer, the application and Windows will look at those locations to see what it needs to download from the server to correct and alter the program.
The purpose of the Package Cache files/folder is to work with and improve the performance of install, update, and restore actions of the applications.
How Package Cache Works?
When you are installing any application Windows OS will first check the package cache if it has any copy of the program already. If there is then windows will use that copy from the package cache. If there is no cache then Windows will download it from the internet.
What if I remove those files and folders?
These Package Cache files may contain all of your settings and installed packages that you have created or built over time, and no one wants to delete those files and recreate the same information. Also, Microsoft doesn't recommend you delete it as well.
It's even scarier if you delete all the files thinking they're just cache files kept by the application, and you will find your application stops functioning properly.
Also, if you deleted those files, you may not be able to uninstall the applications because the applications may be looking for something in those files/folders and not finding it, resulting in an error like this: and sometimes forcing you to reinstall your OS or restore to a previous stable state.
Also, deleting those files may cause some applications to take longer to load, process your request, and begin downloading those packages again if they do not exist on the computer and this may take a long time to download those packages again.
Are they temporary files?
Ans: They are not temporary files and they contain very important data needed for the application for its operations.
How to change the location of Package Cache files?
Assuming you have a limited number of files, especially if you have an SSD, having those large package cache files/folders will fill up your SSD and it will be necessary for you to move those files/folders to separate locations.
We must move those files/folders in any drive letter in such a way that applications will automatically search for them in the new location without any problem for application.
Using mklink command
mklink command is a useful command generally used for creating symbolic links. It is available on most Windows OS. Note that it will require admin privileges to run mklink command.
|Creates a symbolic directory link.
|Creates a hard link
|Creates a directory junction
|New Name for Symbolic Link
|The path is either relative /absolute of the new link.
We have enclosed paths in quotes because the link may contain a space in between them.
Here we have created symbolic links from "C:\ProgramData\PackageCache" to "D:\BackupCache\ProgramData\PackageCache". Now programs which have package cache in "C:\ProgramData\PackageCache" package cache then next time it will search it at "D:\BackupCache\ProgramData\PackageCache"
And you will get a success message like:
Do package cache files get deleted after I uninstalled Visual Studio?
Ans: In my case, I have uninstalled Visual Studio IDE, even though those package cache files referring to Visual Studio are not deleted.
How to disable the package cache?
You can start the installer with the —nocache switch before installing, modifying, or repairing Visual Studio or other products with the new installer. (source)
This procedure will remove any existing packages for the Visual Studio product and will prevent any packages from being saved after they have been installed.
If you alter or repair Visual Studio and require packages, they will be installed. They are downloaded automatically and removed once they have been installed from that location.
Does Microsoft recommend deleting Package Cache files?
Microsoft also advised against deleting it, instead recommending that it be moved to another drive, USB, or any other external device.
What is the importance of Caching?
Caching aids in improving the performance of applications installed on a machine.
When should I clear the package cache stored by Visual Studio?
Uninstalling Visual Studio does not always clear the package cache. As a result, you can remove them after uninstalling Visual Studio. After reinstalling Visual Studio, it will add content to package cache files that may be smaller in size than the previous one.
When to move the package Cache?
If you want to work offline, you can copy package cache files to different drives or disks.
What happens if you change the CachePath registry policy?
The cache path specifies how and where the Visual Studio product is downloaded on the client machine.
If you change the path of the Cachepath registry policy after any installations, you must relocate the existing package cache to a new location to ensure that it is secure so that everyone can read it and the Administrator has full control over it. Failure to relocate or secure the existing cache may cause issues with subsequent future installations. (source)
How often should I delete Package Cache?
You can delete the package but you do not need to delete it on a regular basis.