From 26a868f5c33f7e0412a9eeba32e266a5d4b2eec9 Mon Sep 17 00:00:00 2001 From: diao-gaoyang Date: Tue, 26 Aug 2025 19:32:00 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=96=B0=E5=A2=9EprefetchpageV2=E5=92=8CPr?= =?UTF-8?q?efetchOptions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: diao-gaoyang --- api/@ohos.web.webview.d.ts | 65 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/api/@ohos.web.webview.d.ts b/api/@ohos.web.webview.d.ts index 44dec7ebd8..1827a92ca8 100644 --- a/api/@ohos.web.webview.d.ts +++ b/api/@ohos.web.webview.d.ts @@ -5586,6 +5586,26 @@ declare namespace webview { */ prefetchPage(url: string, additionalHeaders?: Array): void; + /** + * Prefetch the resources required by the page, but will not execute js or render the page. + *

API Note:
+ * ‌prefetchPage‌ does not cache resources with Cache-Control: no-store by default, and only allows one prefetch within + * 500ms. + * Prefetch behavior can be customized via ‌prefetchOptions‌, including ignoring Cache-Control: no-store and adjusting + * the throttling interval. + * + * @param { string } url - Which url to preresolve/preconnect. + * @param { Array } [additionalHeaders] - Additional HTTP request header of the URL. + * @param { PrefetchOptions } [prefetchOptions] - Prefetch behavior can be customized via ‌prefetchOptions‌, including + * ignoring Cache-Control: no-store and adjusting the throttling interval. + * @throws { BusinessError } 17100001 - Init error. The WebviewController must be associated with a Web component. + * @throws { BusinessError } 17100002 - Invalid url. + * @syscap SystemCapability.Web.Webview.Core + * @since 21 + * @arkts 1.1&1.2 + */ + prefetchPage(url: string, additionalHeaders?: Array, prefetchOptions?: PrefetchOptions): void; + /** * Preresolve or Preconnect the url. This API can be called before loading the url to make loading faster. * @param { string } url - Which url to preresolve/preconnect. @@ -9202,6 +9222,51 @@ declare namespace webview { constructor(); } + /** + * Defines the PrefetchOptions class. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 21 + * @arkts 1.1&1.2 + */ + class PrefetchOptions { + + /** + * ‌Set prefetch page interval limit. + *

API Note:
+ * Default 500ms (ensures only one successful prefetch within 500ms). + * The interval throttles prefetch frequency to balance performance and resource usage. + * + * @type { int } + * @syscap SystemCapability.Web.Webview.Core + * @since 21 + * @arkts 1.1&1.2 + */ + minTimeBetweenPrefetchesMs: number; + + /** + * Set whether to ignore Cache-Control: no-store‌. + *

API Note:
+ * This setting controls whether prefetch operations bypass the HTTP Cache-Control: no-store directive. + * Important‌: Default behavior (false) aligns with HTTP security standards. Overriding (true) requires explicit risk + * assessment for non-sensitive resources. + * + * @type { boolean } + * @syscap SystemCapability.Web.Webview.Core + * @since 21 + * @arkts 1.1&1.2 + */ + ignoreCacheControlNoStore: boolean; + + /** + * Constructor for PrefetchOptions. + * @syscap SystemCapability.Web.Webview.Core + * @since 21 + * @arkts 1.1&1.2 + */ + Constructor(); + } + /** * Enum type supplied to {@link insertProxyRule} for indicating the scheme filter for proxy. * @enum { number } -- Gitee From 59693f666386be9317ad54ce5eafe082f6d9aa42 Mon Sep 17 00:00:00 2001 From: diao-gaoyang Date: Tue, 26 Aug 2025 20:20:25 +0800 Subject: [PATCH 2/3] =?UTF-8?q?prefetch=E8=BF=BD=E5=8A=A0=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: diao-gaoyang --- api/@ohos.web.webview.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/@ohos.web.webview.d.ts b/api/@ohos.web.webview.d.ts index 1827a92ca8..f9985e9aa5 100644 --- a/api/@ohos.web.webview.d.ts +++ b/api/@ohos.web.webview.d.ts @@ -9237,7 +9237,7 @@ declare namespace webview { * Default 500ms (ensures only one successful prefetch within 500ms). * The interval throttles prefetch frequency to balance performance and resource usage. * - * @type { int } + * @type { number } * @syscap SystemCapability.Web.Webview.Core * @since 21 * @arkts 1.1&1.2 @@ -9259,12 +9259,12 @@ declare namespace webview { ignoreCacheControlNoStore: boolean; /** - * Constructor for PrefetchOptions. + * constructor for PrefetchOptions. * @syscap SystemCapability.Web.Webview.Core * @since 21 * @arkts 1.1&1.2 */ - Constructor(); + constructor(); } /** -- Gitee From 56744227144cb72bab6f3b56c7f5b202647a3b85 Mon Sep 17 00:00:00 2001 From: diao-gaoyang Date: Tue, 26 Aug 2025 20:22:15 +0800 Subject: [PATCH 3/3] =?UTF-8?q?prefetch=E8=BF=BD=E5=8A=A0=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: diao-gaoyang --- api/@ohos.web.webview.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/@ohos.web.webview.d.ts b/api/@ohos.web.webview.d.ts index f9985e9aa5..b5298913c7 100644 --- a/api/@ohos.web.webview.d.ts +++ b/api/@ohos.web.webview.d.ts @@ -9259,7 +9259,7 @@ declare namespace webview { ignoreCacheControlNoStore: boolean; /** - * constructor for PrefetchOptions. + * Constructor for PrefetchOptions. * @syscap SystemCapability.Web.Webview.Core * @since 21 * @arkts 1.1&1.2 -- Gitee