Skip to content

Commit 6a243c6

Browse files
committed
properly cache dynamic content for offline: use networkFirst
1 parent 9376f9a commit 6a243c6

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

build/webpack.client.config.js

+19-5
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,25 @@ if (process.env.NODE_ENV === 'production') {
4949
cacheId: 'vue-hn',
5050
filename: 'service-worker.js',
5151
dontCacheBustUrlsMatching: /./,
52-
staticFileGlobsIgnorePatterns: [/index\.html$/, /\.map$/],
53-
dynamicUrlToDependencies: {
54-
'/': glob.sync('./dist/*.js'),
55-
'/top': glob.sync('./dist/*.js')
56-
}
52+
staticFileGlobsIgnorePatterns: [/\.map$/, /\.json$/],
53+
runtimeCaching: [
54+
{
55+
urlPattern: '/',
56+
handler: 'networkFirst'
57+
},
58+
{
59+
urlPattern: /\/(top|new|show|ask|jobs)/,
60+
handler: 'networkFirst'
61+
},
62+
{
63+
urlPattern: '/item/:id',
64+
handler: 'networkFirst'
65+
},
66+
{
67+
urlPattern: '/user/:id',
68+
handler: 'networkFirst'
69+
}
70+
]
5771
})
5872
)
5973
}

0 commit comments

Comments
 (0)