gpt4 book ai didi

Angular 5 和 Service Worker : How to exclude a particular path from ngsw-config. json

转载 作者:太空狗 更新时间:2023-10-29 16:53:35 25 4
gpt4 key购买 nike

我有 ngsw-config.json(取自 docs ):

    {
"index": "/index.html",
"assetGroups": [{
"name": "app",
"installMode": "prefetch",
"resources": {
"files": [
"/favicon.ico",
"/index.html"
],
"versionedFiles": [
"/*.bundle.css",
"/*.bundle.js",
"/*.chunk.js"
]
}
}, {
"name": "assets",
"installMode": "lazy",
"updateMode": "prefetch",
"resources": {
"files": [
"/assets/**"
]
}
}]
}

在我的网站上有一个指向 RSS 提要 /api/rss 的链接,该链接应该在新的浏览器选项卡中打开,而无需加载 Angular 应用程序。如何将其从请求重定向到 index.html 的资源列表中排除?

UPD:我试过但没有使用以下配置(参见 !/api/rss):

    {
"index": "/index.html",
"assetGroups": [{
"name": "app",
"installMode": "prefetch",
"patterns": ["!/api/rss"],
"resources": {
"files": [
"/favicon.ico",
"/index.html",
"!/api/rss"
],
"versionedFiles": [
"/*.bundle.css",
"/*.bundle.js",
"/*.chunk.js"
]
}
}, {
"name": "assets",
"installMode": "lazy",
"updateMode": "prefetch",
"resources": {
"files": [
"/assets/**"
]
}
}]
}

最佳答案

感谢 Pedro Arantes advice ,我到达了下一个工作配置(参见 dataGroups"maxAge": "0u"):

{
"index": "/index.html",
"dataGroups":
[
{
"name": "api",
"urls": ["/api"],
"cacheConfig": {
"maxSize": 0,
"maxAge": "0u",
"strategy": "freshness"
}
}
],
"assetGroups":
[
{
"name": "app",
"installMode": "prefetch",
"resources": {
"files": [
"/favicon.ico",
"/index.html"
],
"versionedFiles": [
"/*.bundle.css",
"/*.bundle.js",
"/*.chunk.js"
]
}
},
{
"name": "assets",
"installMode": "lazy",
"updateMode": "prefetch",
"resources": {
"files": [
"/assets/**"
]
}
}
]
}

关于Angular 5 和 Service Worker : How to exclude a particular path from ngsw-config. json,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47693093/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com