aboutsummaryrefslogtreecommitdiff
path: root/files/ru/web/api/indexeddb_api
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-14 12:18:12 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-14 12:18:12 -0500
commit869dd2069c695ee7040cd3261713212155819f42 (patch)
tree320a95de75a89686a9df006b90d923aa7fa0d551 /files/ru/web/api/indexeddb_api
parenta5fcfafb665e96cae5d04dfba927db8dcdfd7f14 (diff)
downloadtranslated-content-869dd2069c695ee7040cd3261713212155819f42.tar.gz
translated-content-869dd2069c695ee7040cd3261713212155819f42.tar.bz2
translated-content-869dd2069c695ee7040cd3261713212155819f42.zip
final dump 2020-12-14
Diffstat (limited to 'files/ru/web/api/indexeddb_api')
-rw-r--r--files/ru/web/api/indexeddb_api/browser_storage_limits_and_eviction_criteria/index.html132
1 files changed, 132 insertions, 0 deletions
diff --git a/files/ru/web/api/indexeddb_api/browser_storage_limits_and_eviction_criteria/index.html b/files/ru/web/api/indexeddb_api/browser_storage_limits_and_eviction_criteria/index.html
new file mode 100644
index 0000000000..93f8f9634e
--- /dev/null
+++ b/files/ru/web/api/indexeddb_api/browser_storage_limits_and_eviction_criteria/index.html
@@ -0,0 +1,132 @@
+---
+title: Browser storage limits and eviction criteria
+slug: Web/API/IndexedDB_API/Browser_storage_limits_and_eviction_criteria
+tags:
+ - IndexedDB
+ - данных
+ - клиентская сторона
+translation_of: Web/API/IndexedDB_API/Browser_storage_limits_and_eviction_criteria
+---
+<div>{{DefaultAPISidebar("IndexedDB")}}</div>
+
+<p class="summary">Существует целый ряд веб-технологий, которые хранят данные того или иного рода на стороне клиента (то есть на локальном диске). Процесс, с помощью которого браузер решает, сколько места выделить для хранения веб-данных и что удалить, когда этот предел будет достигнут, не прост и отличается между браузерами. В этой статье описывается, как браузеры определяют, какой локальный контент следует очистить и когда, чтобы освободить необходимое локальное пространство для хранения.</p>
+
+<div class="note">
+<p><strong>Примечание</strong>: приведенная ниже информация должна быть достаточно точной для большинства современных браузеров, но специфика браузера вызывается там, где она известна. Opera и Chrome должны вести себя одинаково во всех случаях. Opera Mini (все еще основанная на presto, серверная визуализация) не хранит никаких данных на клиенте.</p>
+</div>
+
+<h2 id="Какие_технологии_используют_браузерные_хранилища_данных">Какие технологии используют браузерные хранилища данных?</h2>
+
+<p>В Firefox следующие технологии используют хранилище данных браузера для хранения данных, когда это необходимо. В этом контексте мы называем их "квотными клиентами": </p>
+
+<ul>
+ <li><a href="/en-US/docs/Web/API/IndexedDB_API">IndexedDB</a></li>
+ <li><a href="http://asmjs.org/">asm.js</a> кэширование</li>
+ <li><a href="/en-US/docs/Web/API/Cache">Cache API</a></li>
+ <li>Cookies</li>
+</ul>
+
+<div class="note">
+<p><strong>Примечание</strong>: В Firefox веб-хранилище скоро начнет использовать те же инструменты управления хранилищем, что и в этом документе.</p>
+</div>
+
+<div class="note">
+<p><strong>Примечание</strong>: в режиме приватного просмотра большинство хранилищ данных не поддерживается. Данные локального хранилища и файлы cookie все еще хранятся, но они эфемерны — данные удаляются, когда вы закрываете последнее окно приватного просмотра.</p>
+</div>
+
+<p>The "last access time" of origins is updated when any of these are activated/deactivated — origin eviction will delete data for all these quota clients.</p>
+
+<p>In Chrome/Opera, the Quota Management API handles quota management for <a href="/en-US/docs/Web/HTML/Using_the_application_cache">AppCache</a>, <a href="/en-US/docs/Web/API/IndexedDB_API">IndexedDB</a>, WebSQL, and <a href="/en-US/docs/Web/API/File_System_API">File System API</a>.</p>
+
+<h2 id="Different_types_of_data_storage">Different types of data storage</h2>
+
+<p>Even in the same browser, using the same storage method, there are different classes of data storage to understand. This section discusses the different ones you might find in different browsers.</p>
+
+<p>Storage comes in two types:</p>
+
+<ul>
+ <li>Persistent: This is data that is intended to be kept around for a long time. This will only be evicted if the user chooses to (for example, in Firefox you can choose to delete all stored data or only stored data from selected origins by going to <em>Preferences</em> and using the options under <em>Privacy &amp; Security &gt; Cookies &amp; Site Data</em>).</li>
+ <li>Temporary: This is data that doesn't need to persist for a very long time. This will be evicted under a least recently used ({{anch("LRU policy")}}) when {{anch("Storage limits")}} are reached.</li>
+</ul>
+
+<p>In Firefox, when persistent storage is used, the user is given a UI popup to alert them that this data will persist, and asks if they are happy with that. Temporary data storage does not elicit any user prompts.</p>
+
+<p>Storage is temporary by default; developers can choose to use persistent storage for their sites using the {{domxref("StorageManager.persist()")}} method available in the <a href="/en-US/docs/Web/API/Storage_API">Storage API</a>.</p>
+
+<h2 id="Where_is_the_data_stored">Where is the data stored?</h2>
+
+<p>Each storage type represents a separate repository. Here's the actual mapping to directories under a user's Firefox profile (other browsers may differ slightly):</p>
+
+<ul>
+ <li><code>&lt;profile&gt;/storage</code> — the main top-level directory for storages maintained by the quota manager (see below)</li>
+ <li><code>&lt;profile&gt;/storage/permanent</code> — persistent data storage repository</li>
+ <li><code>&lt;profile&gt;/storage/temporary</code> — temporary data storage repository</li>
+ <li><code>&lt;profile&gt;/storage/default</code> — default data storage repository</li>
+</ul>
+
+<div>
+<div class="note">
+<p><strong>Note</strong>: After introducing <a href="/en-US/docs/Web/API/Storage_API">Storage API</a>, the "permanent" folder can be considered obsolete; the "permanent" folder only stores IndexedDB persistent-type databases. It doesn't matter if box mode is "best-effort" or "persistent" — data is stored under &lt;profile&gt;/storage/default.</p>
+</div>
+</div>
+
+<div class="note">
+<p><strong>Note</strong>: In Firefox, you can find your profile folder by entering <code>about:support</code> in the URL bar, and pressing the <em>Show in...</em> button (e.g., <em>Show in Finder</em> on Mac OS X) next to the <em>Profile Folder</em> title.</p>
+</div>
+
+<div class="note">
+<p><strong>Note</strong>: If you are looking around in your Profile at the data stored, you might see a fourth folder: <code>persistent</code>. Basically, the <code>persistent</code> folder was renamed to <code>permanent</code> a while ago to keep upgrades/migration simpler.</p>
+</div>
+
+<div class="note">
+<p><strong>Note</strong>: Users shouldn’t add their own directories or files under <code>&lt;profile&gt;/storage</code>. This will cause storage initialization to fail; for example, {{domxref("IDBFactory.open()", "open()")}} will fire an error event.</p>
+</div>
+
+<h2 id="Storage_limits">Storage limits</h2>
+
+<p>The maximum browser storage space is dynamic — it is based on your hard drive size. The <strong>global limit</strong> is calculated as 50% of free disk space. In Firefox, an internal browser tool called the Quota Manager keeps track of how much disk space each origin is using up, and deletes data if necessary.</p>
+
+<p>So if your hard drive is 500 GB, then the total storage for a browser is 250 GB. If this is exceeded, a process called <strong>origin eviction</strong> comes into play, deleting an entire origin's worth of data until the storage amount goes under the limit again. There is no trimming effect put in place to delete parts of origins — deleting one database of an origin could cause problems with inconsistency.</p>
+
+<p>There's also another limit called <strong>group limit</strong> — this is defined as 20% of the global limit, but it has a minimum of 10 MB and a maximum of 2 GB. Each origin is part of a group (group of origins). There's one group for each eTLD+1 domain. For example:</p>
+
+<ul>
+ <li><code>mozilla.org</code> — group1, origin1</li>
+ <li><code>www.mozilla.org</code> — group1, origin2</li>
+ <li><code>joe.blogs.mozilla.org</code> — group1, origin3</li>
+ <li><code>firefox.com</code> — group2, origin4</li>
+</ul>
+
+<p>In this group, <code>mozilla.org</code>, <code>www.mozilla.org</code>, and <code>joe.blogs.mozilla.org</code> can aggregately use a maximum of 20% of the global limit. <code>firefox.com</code> has a separate maximum of 20%.</p>
+
+<p>The two limits react differently to limits being reached:</p>
+
+<ul>
+ <li>The group limit is also called the "hard limit": it doesn't trigger origin eviction.</li>
+ <li>The global limit is a "soft limit" since there's a chance that some space will be freed and the operation can continue.</li>
+</ul>
+
+<div class="note">
+<p><strong>Note</strong>: The group limit can't be more than the global limit, despite the minimum group limit mentioned above. If you had a really low memory situation where the global limit was, say, 8 MB, then the group limit would also be 8 MB.</p>
+</div>
+
+<div class="note">
+<p><strong>Note</strong>: If the group limit is exceeded, or if origin eviction couldn't free enough space, the browser will throw a <code>QuotaExceededError</code>.</p>
+</div>
+
+<div class="note">
+<p><strong>Note</strong>: In Chrome the soft and hard storage quota limits has changed since <strong>M66</strong>. More information can be found <a href="https://chromium.googlesource.com/chromium/src/+/refs/heads/master/storage/browser/quota/quota_settings.cc#68">here.</a></p>
+</div>
+
+<h2 id="LRU_policy">LRU policy</h2>
+
+<p>When the available disk space is filled up, the quota manager will start clearing out data based on an LRU policy — the least recently used origin will be deleted first, then the next one, until the browser is no longer over the limit.</p>
+
+<p>We track the "last access time" for each origin using temporary storage. Once the global limit for temporary storage is reached (more on the limit later), we try to find all currently unused origins (i.e., ones with no tabs/apps open that are keeping open datastores). These are then sorted according to "last access time." The least recently used origins are then deleted until there's enough space to fulfill the request that triggered this origin eviction.</p>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li><a href="http://www.html5rocks.com/en/tutorials/offline/quota-research/">Working with quota on mobile browsers</a>, by<a href="http://blog.agektmr.com" title="Eiji Kitamura"> Eiji Kitamura.</a> A detailed analysis of client-side storage on mobile browsers.</li>
+ <li><a href="https://developers.google.com/web/updates/2011/11/Quota-Management-API-Fast-Facts">Quota Management API: Fast Facts</a>, by<a href="http://blog.agektmr.com" title="Eiji Kitamura"> Eiji Kitamura.</a> A look at the Quota Management API in Chrome/Blink (which should include Opera, too).</li>
+</ul>