5

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?

  • What's the operating system? Which Chrome version are you currently using? – and31415 Jun 16 '14 at 23:00
  • Windows 8.1 x64, Chrome 34.0.1847.137. – user541686 Jun 16 '14 at 23:02
  • Latest version is 35.0.1916.153. Did you downgrade it on purpose or is it just out-of-date? Since your operating system is 64-bit and Chrome is 32-bit, the actual path would be SOFTWARE\Wow6432Node\Policies\Google\Chrome. To check whether the browser is actually reading the policies you can use Process Monitor. – and31415 Jun 16 '14 at 23:16
  • @and31415: Three things: (1) You're wrong about that, for HKCU the 64-bit path is used. (2) Even if it wasn't, how is the path even relevant when I already told you I get the same behavior when I specify --disk-cache-size on the command line? (3) Regarding the updates: it's intentionally a lower version, but that has nothing to do with this question as far as I'm aware. Do you get a different behavior on a later version of Chrome? I still don't know if you can reproduce my problem. – user541686 Jun 16 '14 at 23:19
  • @and31415: As for process monitor, it seems like Chrome doesn't read any of the DiskCacheSize entries, irrespective of whether I put them in HKCU or HKLM, 32-bit or 64-bit. However that's still irrelevant because disk-cache-size doesn't work on the command line either. – user541686 Jun 16 '14 at 23:36
9

Change the Chrome cache size

The cache size is not fixed; rather, it can change dynamically:

#28 rvargas@chromium.org

The default size is calculated at start time and depends on the available disk space in the volume where the cache is located.

We try hard to use at least 80 [MiB], with the size growing slowly until it caps at about 320 [MiB] (for 32 [GiB] free).

This is of course subject to change depending on overall measured performance.

Source: Issue 96264 - chromium - Implement a policy to clear browser cache on shut down

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:

chrome://net-internals/#httpCache

Using a command-line switch

  1. Copy the Google Chrome application shortcut, and paste it to the desktop.

  2. Right-click the pasted shortcut, and choose Properties from the context menu.

  3. Edit the Target field by adding a space character and the following switch at the very end:

    --disk-cache-size=<amount in bytes>
    

    For example, to set a 32 MiB limit (33554432 bytes) the ending part should look like this:

    chrome.exe --disk-cache-size=33554432
    
  4. 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.

  1. Log on with an administrator account.

  2. Download the official policy templates.

  3. Open the download archive (e.g. using 7-Zip). Navigate to the windows folder, and extract the admx folder somewhere.

  4. The admx folder contains different subfolders named after a culture name which contain localization strings. There's also a chrome.admx file which is the actual template. Copy it in the PolicyDefinitions folder, which is usually located here:

     C:\Windows\PolicyDefinitions
    

    Then copy the chrome.adml localization file matching the system locale in the corresponding PolicyDefinitions subfolder.

  5. Start gpedit.msc.

  6. Navigate to Computer Configuration > Administrative Templates > Google > Google Chrome.

  7. Double-click the Set disk cache size in bytes setting, enable it, and choose the desired amount. Click OK when you're done.

At least Windows XP SP2.

Configures the cache size that Google Chrome will use for storing cached files on the disk.

If you set this policy, Google Chrome will use the provided cache size regardless whether the user has specified the --disk-cache-size flag or not. The value specified in this policy is not a hard boundary but rather a suggestion to the caching system, any value below a few megabytes is too small and will be rounded up to a sane minimum.

If the value of this policy is 0, the default cache size will be used but the user will not be able to change it.

If this policy is not set the default size will be used and the user will be able to override it with the --disk-cache-size flag.

Source: Policy List - The Chromium Projects

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:

Note: starting with Chrome 28, policies are loaded directly from the Group Policy API on Windows. Policies manually written to the registry will be ignored. See http://crbug.com/259236 for details.

Starting with Google Chrome 35, policies are read directly from the registry if the workstation is joined to an Active Directory domain; otherwise the policies are read from GPO.

Source: Policy List - The Chromium Projects

This can be confirmed by Process Monitor. Whether it's intentional or not, there are a few exceptions:

HKEY_CURRENT_USER\Software\Policies\Google\Chrome\MetricsReportingEnabled
HKEY_CURRENT_USER\Software\Policies\Google\Chrome\UserDataDir
HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome\MetricsReportingEnabled
HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome\UserDataDir
HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Update\Update{8A69D345-D564-463c-AFF1-A69D9E530F96}
HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Update\UpdateDefault
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Policies\Google\Chrome\MetricsReportingEnabled
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Policies\Google\Chrome\UserDataDir
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Policies\Google\Update\Update{8A69D345-D564-463c-AFF1-A69D9E530F96}
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Policies\Google\Update\UpdateDefault

Aside from the main HTTP cache, Chrome also use other folders which can take extra space:

The 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:

  1. Install Chrome.
  2. Ensure the volume where the Cache folder is stored has more than 32 GiB of free space.
  3. Set the homepage to about:blank to prevent a dirty cache on startup.
  4. Clear all cached images and files from the beginning of time.
  5. Close the browser.

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:

@echo off
setlocal
setlocal enabledelayedexpansion

set exePath=%localappdata%\Google\Chrome\Application

if not "%~1" == "" (
start "%~n0" /d "%exePath%" "chrome.exe" "%~1"
pause >nul
)

pushd "%~dp0"
set /a counter=1

for /f "usebackq" %%G in (`findstr /i "^https*://" "samples.txt"`) do (
echo Load sample !counter!
start "%~n0" /d "%exePath%" "chrome.exe" "%%~G"
set /a counter += 1
pause >nul
)

popd
endlocal
pause & exit /b

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

http://www.tumblr.com/search/gif+1
http://www.tumblr.com/search/gif+2
http://www.tumblr.com/search/gif+3
http://www.tumblr.com/search/gif+4
http://www.tumblr.com/search/gif+5
http://www.tumblr.com/search/gif+6
http://www.tumblr.com/search/gif+7
http://www.tumblr.com/search/gif+8

Results

After loading hundreds of files, the cache size was 334128469 bytes (about 318.65 MiB). The trim counter was set to 0x15c, meaning over 300 of the oldest entries were discarded to make room for new ones.

Cache type: Blockfile Cache
Create error: 0x0
Create hit: 0xa8
Create miss: 0x0
Current size: 334128469
Doom cache: 0x0
Doom entry: 0x3c
Doom recent entries: 0x0
Entries: 833
Fatal error: 0x0
Get rankings: 0x0
Invalid entry: 0x0
Last report: 0x2e5b3bec502446
Last report timer: 0x0
Max entries: 0x1a
Max size: 335544320
Open entries: 0x9
Open hit: 0x34
Open miss: 0xad
Open rankings: 0x39c68
Pending IO: 0
Read data: 0x4db
Resurrect hit: 0x2
Size00: 0x0000052f
Size01: 0x00000005
Size02: 0x00000017
Size03: 0x00000014
Size04: 0x00000002
Size05: 0x00000001
Size06: 0x00000004
Size07: 0x00000005
Size08: 0x00000002
Size09: 0x00000003
Size10: 0x00000004
Size11: 0x00000009
Size12: 0x0000001a
Size13: 0x00000019
Size14: 0x00000012
Size15: 0x00000006
Size16: 0x00000020
Size17: 0x00000013
Size18: 0x00000012
Size19: 0x00000032
Size20: 0x00000074
Size21: 0x00000083
Size22: 0x00000000
Size23: 0x00000000
Size24: 0x00000000
Size25: 0x00000000
Size26: 0x00000000
Size27: 0x00000000
Timer: 0xe
Trim entry: 0x15c
Write data: 0x4c171
unused: 0x0

Test A2

Just like test A1, with a twist: the cache gets limited to 32 MiB.

Flags

--disk-cache-size=33554432

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.

Cache type: Blockfile Cache
Create error: 0x0
Create hit: 0xb6
Create miss: 0x0
Current size: 33280014
Doom cache: 0x0
Doom entry: 0x2f5
Doom recent entries: 0x0
Entries: 139
Fatal error: 0x0
Get rankings: 0x0
Invalid entry: 0x0
Last report: 0x2e5b3c19894813
Last report timer: 0x0
Max entries: 0x18
Max size: 33554432
Open entries: 0x9
Open hit: 0x4f
Open miss: 0xb9
Open rankings: 0x34e76
Pending IO: 0
Read data: 0x4d6
Resurrect hit: 0x1
Size00: 0x000000e5
Size01: 0x00000005
Size02: 0x00000010
Size03: 0x00000006
Size04: 0x00000000
Size05: 0x00000001
Size06: 0x00000003
Size07: 0x00000003
Size08: 0x00000001
Size09: 0x00000002
Size10: 0x00000002
Size11: 0x00000000
Size12: 0x00000002
Size13: 0x00000003
Size14: 0x00000001
Size15: 0x00000002
Size16: 0x00000006
Size17: 0x00000008
Size18: 0x00000002
Size19: 0x00000006
Size20: 0x00000010
Size21: 0x0000000a
Size22: 0x00000000
Size23: 0x00000000
Size24: 0x00000000
Size25: 0x00000000
Size26: 0x00000000
Size27: 0x00000000
Timer: 0xe
Trim entry: 0x2fc
Write data: 0x4239f
unused: 0x0

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:

jpeg "file size 15.92 mb" site:wikimedia.org

As the cache is set to 32 MiB, each entry is limited to 4 MiB.

Flags

--disk-cache-size=33554432

Samples

http://upload.wikimedia.org/wikipedia/commons/b/ba/Langesund_og_Lang%C3%B8ya_01.jpg
http://upload.wikimedia.org/wikipedia/commons/9/9d/Balloons_of_Happiness.jpg
http://upload.wikimedia.org/wikipedia/commons/1/1e/Kannonzaki_01.jpg
http://upload.wikimedia.org/wikipedia/commons/5/51/Fraser_Ship_Yard_tug_boat%3B_Superior_WI_-b.jpg
http://upload.wikimedia.org/wikipedia/commons/4/46/Val%C3%A8ncia_micalet.jpg

Results

Out of the five samples, just three of them were actually cached.

Cache type: Blockfile Cache
Create error: 0x0
Create hit: 0x5
Create miss: 0x0
Current size: 7305845
Doom cache: 0x0
Doom entry: 0x2
Doom recent entries: 0x0
Entries: 3
Fatal error: 0x0
Get rankings: 0x0
Invalid entry: 0x0
Last report: 0x2e5b3c78282e93
Last report timer: 0x0
Max entries: 0x0
Max size: 33554432
Open entries: 0x0
Open hit: 0x0
Open miss: 0x5
Open rankings: 0xa
Pending IO: 0
Read data: 0x0
Resurrect hit: 0x0
Size00: 0x00000006
Size01: 0x00000000
Size02: 0x00000000
Size03: 0x00000000
Size04: 0x00000000
Size05: 0x00000000
Size06: 0x00000000
Size07: 0x00000000
Size08: 0x00000000
Size09: 0x00000000
Size10: 0x00000000
Size11: 0x00000000
Size12: 0x00000000
Size13: 0x00000000
Size14: 0x00000000
Size15: 0x00000000
Size16: 0x00000000
Size17: 0x00000000
Size18: 0x00000000
Size19: 0x00000000
Size20: 0x00000001
Size21: 0x00000001
Size22: 0x00000001
Size23: 0x00000002
Size24: 0x00000000
Size25: 0x00000000
Size26: 0x00000000
Size27: 0x00000000
Timer: 0x1
Trim entry: 0x0
Write data: 0x1e74
unused: 0x0

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.

Cache type: Blockfile Cache
Create error: 0x0
Create hit: 0x5
Create miss: 0x0
Current size: 32341906
Doom cache: 0x0
Doom entry: 0x0
Doom recent entries: 0x0
Entries: 5
Fatal error: 0x0
Get rankings: 0x0
Invalid entry: 0x0
Last report: 0x2e5b3c6aae7b97
Last report timer: 0x0
Max entries: 0x0
Max size: 335544320
Open entries: 0x0
Open hit: 0x0
Open miss: 0x5
Open rankings: 0x4
Pending IO: 0
Read data: 0x0
Resurrect hit: 0x0
Size00: 0x0000000a
Size01: 0x00000000
Size02: 0x00000000
Size03: 0x00000000
Size04: 0x00000000
Size05: 0x00000000
Size06: 0x00000000
Size07: 0x00000000
Size08: 0x00000000
Size09: 0x00000000
Size10: 0x00000000
Size11: 0x00000000
Size12: 0x00000000
Size13: 0x00000000
Size14: 0x00000000
Size15: 0x00000000
Size16: 0x00000000
Size17: 0x00000000
Size18: 0x00000000
Size19: 0x00000000
Size20: 0x00000001
Size21: 0x00000001
Size22: 0x00000001
Size23: 0x00000001
Size24: 0x00000001
Size25: 0x00000000
Size26: 0x00000000
Size27: 0x00000000
Timer: 0x1
Trim entry: 0x0
Write data: 0x2c6a
unused: 0x0
|improve this answer|||||
  • 1
    It certainly can't be true that all policies are stored there, because I know for a fact that Chrome respects UserDataDir inside HKCU... are you sure DiskCacheSize isn't valid there either? – user541686 Jun 16 '14 at 22:32
  • Thanks. I understand it doesn't enforce a limit, but "rounding up" 32 MB to 288 sounds a little ridiculous, I don't think that can be the reason why this is happening. – user541686 Jun 16 '14 at 22:54
  • 1
    @Mehrdad I suppose you already tried clearing the cache? Can you reproduce the same behavior if you remove the policy and use the --disk-cache-size flag instead? – and31415 Jun 16 '14 at 22:56
  • Yes I've tried both, and yes I can reproduce the problem even with the command-line flag. Here's a question: can you reproduce this problem? Does your Chrome really respect your cache size settings? – user541686 Jun 16 '14 at 23:02
  • @Mehrdad I tried latest Chrome and version 34.0.1847.137, and the cache size I set was successfully applied and honored, regardless if I used the --disk-cache-size flag or applied the related group policy setting. As of version 28, Chrome ignores policies which are manually set in the registry. I've since rewrote my answer to provide more details, observations, and some tests. – and31415 Jun 26 '14 at 9:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.