【发布时间】:2019-05-04 11:42:39
【问题描述】:
我的 PWA,最近使用 Vue CLI 3 创建,效果很好,只是我无法让它缓存我的字体超过max-age=0。
这是我的设置:
vue.config.sys(适用部分)
module.exports = {
pwa: {
workboxOptions: {
exclude: [/\.eot$/, /\.ttf$/],
clientsClaim: true,
skipWaiting: true,
navigateFallback: 'index.html',
runtimeCaching: [
{
urlPattern: /\.(?:woff|woff2)$/,
handler: 'cacheFirst',
options: {
// Use a custom cache name for this route.
cacheName: 'fonts',
// Configure custom cache expiration.
expiration: {
maxEntries: 50,
maxAgeSeconds: 30 * 24 * 60 * 60, // 30 days
// Automatically cleanup if quota is exceeded.
purgeOnQuotaError: true,
},
},
},
],
},
},
};
结果 service-worker.js(使用默认 GenerateSW 模式)
.htaccess(文件夹应用程序来自)
RewriteEngine On
# Redirects http calls to their equivalent https URL
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# A simple catch-all fallback route used when the URL entered by the user
# doesn't match any of the provided app routes. This code is needed when
# using history mode in vue-router.
FallbackResource index.html
# Prevents directory viewing from a browser window.
Options -Indexes
Chrome Dev Tools Cache Storage Screen Grab
我错过了什么?
【问题讨论】:
标签: vuejs2 service-worker progressive-web-apps cache-control workbox-webpack-plugin