0
私のサイトで素材アイコンとロボフォントを使用し、sw-precache runtimeCaching APIを使用してキャッシュしようとしましたが、私はそれを正しくやっているかどうかわからない。キャッシュからこれらのファイルを取得するには、サービス担当者が必要です。ここに私のコードです。私はこれらのリンクをキャッシュしようとしているsw-precache runtimeCachingを使用してgoogleapis.comをキャッシュする方法
gulp.task('create-sw', ['watchCss', 'watchJS'], callback => {
preCache.write(path.join('.', 'sw.js'), {
runtimeCaching: [{
urlPattern: /^https:\/\/fonts\.googleapis\.com$/,
handler: 'cacheFirst',
options: {
cache: {
maxEntries: 10,
name: 'google-apis'
}
},
}],
staticFileGlobs: [
'./script.js',
'./manifest.json',
'./app/**/*.{html,json}',
'./dist/**/*.{js,css,eot,ttf,woff,woff2}',
'./**/*.{png,jpeg,jpg,svg,gif}',
'./index.html',
],
stripPrefix: '.',
maximumFileSizeToCacheInBytes: 15000000,
}, callback)
});
:
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:regular,bold,italic,thin,light,bolditalic,black,medium&lang=en">
'urlPattern'正規表現から末尾の' $ '文字を削除してみてください。 –