I've set HKEY_CURRENT_USER\Software\Policies\Google\Chrome\DiskCacheSize
to a DWORD
value of 0x2000000
(that's 32 MiB), but when I check the size of the Cache
folder in my profile, I see a size of 282 MiB.
Why is this so? Is it a bug, or am I not setting the correct value in the registry?
Best Answer
Change the Chrome cache size
The cache size is not fixed; rather, it can change dynamically:
The behavior described above still applies as of version
35.0.1916.153
. The cache size will also determine the maximum size for cached files, which is 1/8 of the total amount in bytes. Anything bigger won't be cached on the disk.Chrome doesn't provide a way to change its cache size through the user interface. In order to override the default limit you either need to use a specific switch/flag or enable a group policy setting.
Before proceeding, make sure empty the entire cache and then close the browser. To check whether the changes were applied successfully you can use this internal page afterwards:
Using a command-line switch
Copy the Google Chrome application shortcut, and paste it to the desktop.
Right-click the pasted shortcut, and choose Properties from the context menu.
Edit the Target field by adding a space character and the following switch at the very end:
For example, to set a 32 MiB limit (33554432 bytes) the ending part should look like this:
Click OK to apply the changes. Whenever you need to start Chrome, use the modified shortcut.
Through the Group Policy Editor
Note The following steps apply to Windows Vista and later. Only Business/Professional/Pro or higher editions are supported.
Log on with an administrator account.
Download the official policy templates.
Open the download archive (e.g. using 7-Zip). Navigate to the
windows
folder, and extract theadmx
folder somewhere.The
admx
folder contains different subfolders named after a culture name which contain localization strings. There's also achrome.admx
file which is the actual template. Copy it in thePolicyDefinitions
folder, which is usually located here:Then copy the
chrome.adml
localization file matching the system locale in the correspondingPolicyDefinitions
subfolder.Start
gpedit.msc
.Navigate to Computer Configuration > Administrative Templates > Google > Google Chrome.
Double-click the Set disk cache size in bytes setting, enable it, and choose the desired amount. Click OK when you're done.
Additional information
In case the cache folder takes more space than reported, that means there are some leftovers that were left behind. The easiest way to get rid of them is to close the browser, and manually delete all cached files. A brand new cache will be created next time the browser is started.
When it comes to group policies, manually editing the registry is not supported:
This can be confirmed by Process Monitor. Whether it's intentional or not, there are a few exceptions:
Aside from the main HTTP cache, Chrome also use other folders which can take extra space:
Application Cache
- HTML5 Application CacheGPUCache
- GPU shader cacheIndexedDB
- HTML5 Indexed DatabaseMedia Cache
- Multimedia-optimized cache (audio and video clips)Local Storage
/Session Storage
- Web storage cachePnaclTranslationCache
- Portable Native Client Translation CacheThe media cache can be limited to a fixed amount of bytes either using a switch or by enabling the related policy setting. You can't really limit the application cache or the GPU shader cache; you can just disable them through switches. There's no way to tweak the rest.
Further reading
Testing the cache limit
Here's the procedure I followed before running the tests below:
Cache
folder is stored has more than 32 GiB of free space.about:blank
to prevent a dirty cache on startup.All results shown are for Chrome version
34.0.1847.137
running on Windows 7 SP1 x86 (32-bit). The cache was emptied before each test, and there were no noticeable differences in cache behavior when using latest Chrome version.Batch script
To automate the tests I created a batch script:
It has only one parameter, which is used to start Chrome with specific flags. The script parses a
samples.txt
file, collecting all the URLs and open them one at a time. When each sample has finished loading and rendering, press any key to load the next one. The executable path might need to be adjusted.Test A1
The goal of the test is to check whether the maximum cache size is a true boundary. The fastest way to prove that is to load some image-filled website: as long as there's enough content, you should quickly reach the cache limit.
Flags
None
Samples
Results
After loading hundreds of files, the cache size was
334128469
bytes (about 318.65 MiB). The trim counter was set to0x15c
, meaning over 300 of the oldest entries were discarded to make room for new ones.Test A2
Just like test A1, with a twist: the cache gets limited to 32 MiB.
Flags
Samples
Same as test A1.
Results
The cache reached a total size of about 31.74 MiB. Compared to test A1, a tighter limit generated definitely less cached entries, and more discarded ones.
Test B1
While shrinking the cache to 32 MiB, five image samples are loaded. Their size range from 16 MiB to 1 MiB halving each time, minus 0.5% to account rounding errors. For example, to search a 15.92 MiB image I used the following search query:
As the cache is set to 32 MiB, each entry is limited to 4 MiB.
Flags
Samples
Results
Out of the five samples, just three of them were actually cached.
Test B2
Similar to test B1 without cache-tweaking flags.
Flags
None
Samples
Same as test B1.
Results
Unlike test B1, all five samples were cached. The cache size reached about 30.84 MiB, which was the expected amount.