Bit Blazor Serviceworker Update Progress (BitBswup)
to use BitBswup, please follow these steps:
Install the
Bit.Tooling.Bswup
nuget packageDisable static file caching.You can follow below code in
Startup.cs
file
In the default document (
_Host.cshtml
,index.html
or_Layout.cshtml
), add anautostart = "false"
attribute and value to the tag for the Blazor script.
In the default document (
_Host.cshtml
,index.html
or_Layout.cshtml
), add theBit.Tooling.Bswup
reference after the tag for the Blazor script.
scope: The scope of the service worker determines which files the service worker controls. You need more about that read it.
log: The log level for log provider. log options:
info
,verbose
,debug
,error
sw: The sw is name and path service worker file.
handler: The name of handler for the service worker events
You can not specify the values of the attributes, and use the default values which are equal to the above values.
Add a handler in the simplest way possible, like the below code. or you can add a handler with a progress process bar like the bitBswupHandler on the sample in the index.html file of the demo project in this repo.
Configure additional settings in the service worker file (based on the sample shown in the
service-worker.js
file of the demo project)
Service Worker
self.assetsInclude
: The list of files or regex of files to be cached.self.assetsExclude
: The list of files or regex of files that should not be cached.self.defaultUrl
: The default page url.When use_Host.cshtml
set/
self.prohibitedUrls
: The list of files or regex of files that should not be accessed.self.assetsUrl
: The url address of service worker assets.self.externalAssets
: The list of external assets.If don't useindex.html
for default url you should add this{ "url": "/" }
item.self.caseInsensitiveUrl
: If set true you can check case insensitive url in the cache process.self.serverHandledUrls
: The list of urls or regex that do not enter the service worker process. ex.api
self.serverRenderedUrls
: The list of urls or regex that should be cached by the server after rendering. ex.about.html
Last updated