更新限制
這份文件適用於以下方法:Update API (v4):threatListUpdates.fetch。
設定限制
更新本機資料庫 (請參閱資料庫更新) 時,用戶端可以使用 threatListUpdates.fetch 要求中的 maxUpdateEntries
和 maxDatabaseEntries
欄位指定大小限制。用戶端應設定限制,維持用戶端 RAM、磁碟和頻寬的可預測使用量,並因應清單增長情形。
- 用戶端可以指定項目更新回應大小上限 (
maxUpdateEntries
),例如 1 個項目 = 新增 1 個或 1 次移除。
- 用戶端可在項目數量中指定資料庫大小上限 (
maxDatabaseEntries
)。資料庫中絕大多數項目都是 4 位元組雜湊前置字串,因此可以合理假設 1 個項目 ↓ 4 個位元組。
頻寬與儲存空間
雖然用戶端可以為更新回應和資料庫大小指定任意大小,但安全瀏覽伺服器只會預先產生數量有限的可能更新回應和資料庫大小。
- 用戶端應使用更新回應大小 (
maxUpdateEntries
) 來限制頻寬用量。
- 用戶端應使用資料庫大小 (
maxDatabaseEntries
),限制裝置所需的 RAM 或磁碟儲存空間量。
這兩項限制都會影響正在更新的資料庫大小,因此會影響提供給使用者的保護程度 (也就是說,本機資料庫大小越大,防護能力越佳)。
設定限制的指南
安全瀏覽清單的大小可能會逐漸或突然改變,用戶端應為清單更新要求設定 maxUpdateEntries
,這樣會限制清單更新回應大小上限,並在無法處理大型更新時提升可靠性。
如果沒有任何更嚴格的規定或較不嚴格的要求,Google 建議使用 maxUpdateEntries=16777216
。假設一般清單項目大小是每個雜湊前置字串 4 個位元組,相當於每個清單約 67 MB。Google 建議為行動用戶端使用較小的 maxUpdateEntries=2097152
,因為這類限制通常較不強大。在一般清單項目大小中,每個雜湊前置字串各為 4 個位元組,這相當於每個清單約 8 MB。
安全瀏覽清單的大小和成長率有所不同。不過,用戶端應根據每份清單允許的記憶體上限或頻寬用量,為所有清單設定相同的限制。
為提高可靠性,Google 建議用戶端實作遙測功能以偵測記憶體或頻寬過度用量,並採用可快速將新限制提供給用戶端的機制。
用戶端狀態
安全瀏覽伺服器絕對不會傳送會將用戶端保持在過時狀態的更新,且用戶端將在每次更新要求後完全處於最新狀態。舉例來說,如果用戶端目前有一個資料庫為 4096 個項目,但只想下載最多 2048 deltas,那麼當用戶端實際過時時,伺服器可能會將用戶端重設為 2048 資料庫。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2023-12-18 (世界標準時間)。
[null,null,["上次更新時間:2023-12-18 (世界標準時間)。"],[[["The Safe Browsing API allows clients to set constraints on update and database sizes to manage resource usage."],["Clients can limit bandwidth with `maxUpdateEntries` and storage with `maxDatabaseEntries` to optimize performance."],["Google provides recommended constraint values for different client types to balance protection and resource consumption."],["The Safe Browsing server ensures clients remain up-to-date even with constrained updates, potentially resetting the database if necessary."]]],["Clients updating local databases via the `threatListUpdates.fetch` API can set size constraints using `maxUpdateEntries` (for update response size, limiting bandwidth) and `maxDatabaseEntries` (for database size, limiting storage). Google recommends `maxUpdateEntries=16777216` (67MB) for most clients and `2097152` (8MB) for mobile. These constraints should be consistently applied across all lists, with telemetry to detect overusage. The server ensures clients are always fully updated, potentially resetting to smaller databases if necessary.\n"]]