0
我正在使用sw預緩存來管理我的服務人員。讓我們說我的網站是abc.com,服務人員正在這個網站上運行,並通過url加載abc.com/service-worker.jssw預緩存 - 從不同域加載的資產的運行時緩存
所有的css和js都是從不同的網址加載來優化目的我們說xyz.com
現在運行緩存時我提供
{
// See https://github.com/GoogleChrome/sw-toolbox#methods
urlPattern: '*.css',
handler: 'fastest',
// See https://github.com/GoogleChrome/sw-toolbox#options
options: {
cache: {
maxEntries: 20,
name: 'css-cache'
}
}
}
這隻能從網址abc.com/style/style.css緩存CSS和不xyz.com/style/test.css
我試過
{
// See https://github.com/GoogleChrome/sw-toolbox#methods
urlPattern: 'https:\/\/xyz\.com\/*.js',
handler: 'fastest',
// See https://github.com/GoogleChrome/sw-toolbox#options
options: {
cache: {
maxEntries: 20,
name: 'js-cache'
},
// urlPattern: /\.googleapis\.com\//,
}
}
但都是徒勞的。如果有人遇到同樣的問題,任何幫助正確的方向將不勝感激。