日本語

Check and Clear Site Storage Usage in Chrome DevTools

​​Chrome DevTools​IndexedDB,JavaScript,Storage API

When you open the Storage screen in the Application panel of Chrome DevTools, you can see how much data the currently open site stores in IndexedDB and Cache Storage, shown as numbers per type and as a pie chart. The Clear site data section on the same screen lets you choose which types to delete and clear them all at once. This is useful for checking whether the cache of an offline-capable web app (PWA) keeps growing, or for testing what happens when storage space runs low.

On a test page, I put data into IndexedDB and Cache Storage, then compared the numbers shown on screen with the values obtained by the page's JavaScript.

Note

The test environment was Ubuntu 24.04, Node.js 22, and Chrome for Testing 158.0.8127.36 (the build bundled with Playwright). Because the test environment has no screen, I ran Chrome in a normal window on a virtual display (Xvfb) and displayed DevTools at the bottom of the window. I operated DevTools by sending mouse clicks and key presses from a script. The DevTools UI was in English. The page was served from a Node.js server at http://localhost:8080/. I did not test macOS or Windows Chrome, the regular retail Chrome build, Service Worker registration, saving to the File system (Origin Private File System), the behavior of clearing Cookies and Third-party cookies, or Incognito windows.

Open the Storage screen

  1. Open the site you want to examine, then open DevTools.
  2. Open the Application panel. If you cannot see the tab, press Ctrl + Shift + P (Command + Shift + P on macOS) to open the command menu, then choose "Show Application".
  3. In the list on the left, under the Application heading, select Storage, which comes after Manifest and Service workers.

On the right, the origin of the page currently open (http://localhost:8080/ in the test environment), along with the Clear site data and Usage sections, is displayed. The official Application panel documentation (in English) also describes this screen as showing a pie chart of usage per storage type, and says you can clear a site's data or change the storage quota to test behavior.

Check total usage and the breakdown in the Usage section

From the page's JavaScript, I stored a 5 MiB Blob in IndexedDB, a 3 MiB response in Cache Storage, and a 100 KiB string in localStorage. I did not press anything in DevTools, but one second later the Usage section had changed as follows.

The Usage section of the Storage screen. Below the sentence "8.5 MB used out of 162,332 MB storage quota" is a pie chart with 8.5 MB in the center. On the right is the breakdown: 5.3 MB IndexedDB, 3.1 MB Cache storage, and 8.5 MB Total.
Usage section right after putting 5 MiB into IndexedDB and 3 MiB into Cache Storage

The top sentence, "8.5 MB used out of 162,332 MB storage quota", means that this site is currently using 8.5 MB, and its quota is 162,332 MB. The pie chart and breakdown below show that IndexedDB uses 5.3 MB and Cache storage uses 3.1 MB.

At the same time, I compared these with the values returned by calling navigator.storage.estimate() in the page. The results were as follows.

DevTools Usage section Page estimate()
Total 8.5 MB usage: 8,466,944 bytes
IndexedDB 5.3 MB usageDetails.indexedDB: 5,320,704 bytes
Cache Storage 3.1 MB usageDetails.caches: 3,146,240 bytes

DevTools uses MB as 1,000,000 bytes, so 8,466,944 bytes is displayed as 8.5 MB. If you divide by 1 MiB (1,048,576 bytes), you get 8.07, so if your code converts to MiB for display, the numbers will look slightly different.

The 100 KiB stored in localStorage was not included in either the total or the breakdown. The web.dev article on browser storage (in English) also explains that the value returned by estimate() covers the usage of IndexedDB and the Cache API. localStorage and sessionStorage have separate limits, and according to the MDN explanation of storage quotas (in English), each is limited to 5 MiB per origin.

The quota numbers differed between DevTools and the page

The quota of 162,332 MB in the Usage section was 60% of the test environment's disk size (270,553,174,016 bytes). The web.dev article and the MDN explanation say that in Chrome, a single origin can use up to 60% of the total disk.

On the other hand, the quota from the page's estimate() was 10,737,418,240 bytes (10 GiB) before any data was stored. After storing data it was 10,745,885,184 bytes, which equals the current usage plus 10 GiB. In the test environment, the quota shown in DevTools and the quota visible to the page's JavaScript were not the same.

Lower the quota to test behavior when space runs out

When you check the Simulate custom storage quota box below the Usage section, a numeric field appears. Entering a value in MB here temporarily lowers the quota for this site. (The web.dev article also describes this procedure as a way to test quotas.)

In the test environment, typing 20 in the field alone did not change the display. Pressing Enter changed the Usage sentence to "8.5 MB used out of 20.0 MB (custom) storage quota". With this setting in place, I wrote the following data from the page's JavaScript one item at a time, with these results.

Data written Result
15 MiB response to Cache Storage Failed with QuotaExceededError: Quota exceeded.
15 MiB ArrayBuffer to IndexedDB Succeeded
15 MiB Blob to IndexedDB Succeeded
1 MiB ArrayBuffer to IndexedDB (after usage had already passed 20 MB) Succeeded
1000 KiB string to localStorage Succeeded
The Simulate custom storage quota box is checked, and the numeric field contains 20. The Usage sentence reads "41.0 MB used out of 20.0 MB (custom) storage quota", and the breakdown shows 37.9 MB IndexedDB, 3.1 MB Cache storage, and 41.0 MB Total.
Usage section after writing data with the quota set to 20 MB

Writes to Cache Storage failed, but every write to IndexedDB succeeded, and usage reached 41.0 MB, exceeding the 20.0 MB quota. The web.dev article explains that when the quota is exceeded, both IndexedDB and the Cache API throw QuotaExceededError. However, in the test environment, IndexedDB writes were not stopped even after the quota was exceeded, so I could not trigger an IndexedDB error with this feature.

Also, the quota from the page's estimate() stayed in the 10 GiB range, both after the quota was set to 20 MB and after the page was reloaded (after reloading it was 10,778,423,808 bytes). This setting did not change the quota value visible to the page's JavaScript. If your code calculates remaining space from the estimate() values, those values will not change either.

The Simulate custom storage quota checkbox remained checked even after the page was reloaded. When I unchecked it, the quota display returned to 162,332 MB, and writing 1 MiB to Cache Storage succeeded again.

Select types and clear them all at once

In the Clear site data section at the top of the Storage screen, check the types you want to delete and press Clear selected to clear that site's data all at once. In the test environment, Cache storage, File system, IndexedDB, Local and session storage, Unregister service workers, and Cookies were already checked by default, and only Third-party cookies was unchecked.

I wanted to keep localStorage, so I unchecked Local and session storage before pressing Clear selected.

The Clear site data section. Cache storage, File system, IndexedDB, Unregister service workers, and Cookies are checked, while only the Local and session storage checkbox is unchecked. Third-party cookies is also unchecked. Below is the Clear selected button.
After unchecking Local and session storage

The Usage section and the page's values changed as follows before and after pressing the button.

Before After
Usage sentence 42.1 MB used 0 B used
IndexedDB 37.9 MB (4 items in neko-db) The entire neko-db database was removed
Cache Storage 4.2 MB neko-cache was removed
localStorage memo, memo2 memo, memo2 (kept)

About two seconds after pressing Clear selected, the Usage section showed 0 B. After reloading the page, it still showed 0 B, and the two localStorage entries remained. After pressing Clear selected, the Local and session storage checkbox stayed unchecked.

Warning

Clear selected deletes the data of every checked type. In the default state, Cookies is also checked. If you test this in a browser you use every day, review the checkboxes before pressing the button.

​Posted by 86