语言

BlazorWebView.StaticContentCacheControlProvider 属性

定义

获取或设置一个回调,该值确定 Cache-Control 用于静态内容(如图像、字体或样式表)的标头值(如应用的内容根目录中提供的图像、字体或样式表)。

默认情况下,不会设置回调,所有服务的内容都使用 no-cache, max-age=0, must-revalidate, no-store,这会禁用 WebView 缓存。 提供回调以选择特定资源进行缓存,这可以避免在页面之间导航时重复读取和减少图像重载闪烁。 从回调返回 null 或空字符串,以保留给定请求的默认行为。 缓存条目仍受平台限制、过期和逐出的约束。

从平台的请求处理(可能在后台线程上运行)调用回调,因此它不能直接访问 UI 状态。 如果回调引发,则会记录异常,请求回退到默认标头。

public:
 property Func<Microsoft::AspNetCore::Components::WebView::Maui::BlazorWebViewStaticContentRequest ^, System::String ^> ^ StaticContentCacheControlProvider { Func<Microsoft::AspNetCore::Components::WebView::Maui::BlazorWebViewStaticContentRequest ^, System::String ^> ^ get(); void set(Func<Microsoft::AspNetCore::Components::WebView::Maui::BlazorWebViewStaticContentRequest ^, System::String ^> ^ value); };
public Func<Microsoft.AspNetCore.Components.WebView.Maui.BlazorWebViewStaticContentRequest,string?>? StaticContentCacheControlProvider { get; set; }
member this.StaticContentCacheControlProvider : Func<Microsoft.AspNetCore.Components.WebView.Maui.BlazorWebViewStaticContentRequest, string> with get, set
Public Property StaticContentCacheControlProvider As Func(Of BlazorWebViewStaticContentRequest, String)

属性值

适用于