We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
我用手机打开第二次 必须要网才行?
The text was updated successfully, but these errors were encountered:
new SWPrecacheWebpackPlugin({ dontCacheBustUrlsMatching: /\.\w{8}\./, filename: 'service-worker.js', minify: true, navigateFallback: '/', // 无效的 navigateFallbackWhitelist: [/^(?!\/__).*/], staticFileGlobsIgnorePatterns: [ /\.map$/, /server\.ejs/, /asyncCommonCss\.json/, /react-loadable\.json/, /page/ ], stripPrefix: 'dist', staticFileGlobs: [ 'dist/' + require('./dll/bundle-conf').base.js ], mergeStaticsConfig: true, runtimeCaching: [ { urlPattern: /static\/(css|js)\/page/, handler: 'cacheFirst' }, { urlPattern: /\/.*/, handler: 'networkFirst' } ] })
那是因为首次进入页面只缓存了initial入口的静态资源,在staticFileGlobsIgnorePatterns中配置了忽略资源的规则,/page/忽略做路由按需加载的文件(我是以page-开头命名异步chunkname的),之后才在runtimeCaching中做了动态缓存
initial
staticFileGlobsIgnorePatterns
/page/
page-
runtimeCaching
{ urlPattern: /static\/(css|js)\/page/, handler: 'cacheFirst' },
所以首次进入页面时,该页面需要的资源还没全部加载好,第二次刷新后才能动态缓存到,也就是说第二次刷新了才能离线访问 另外,如果某个页面只是通过前端路由跳转过,而没有刷新过,那只是缓存了这个页面的数据,离线状态下也只能通过前端路由访问,直接刷新是不行的,因为我没有为找不到的url提供一个默认入口,这是服务端渲染的项目,不像spa都是以固定的index.html作为入口,然后可以从index.html加载文件,解析路由渲染页面,暂时还没有好的解决方法,要是有什么想法的话,可以提出来一起讨论下
url
spa
index.html
Sorry, something went wrong.
No branches or pull requests
我用手机打开第二次 必须要网才行?
The text was updated successfully, but these errors were encountered: