Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
224 views
in Technique[技术] by (71.8m points)

webpack-manifest 可以缓存img吗

搜到的说明都是 cache css js 可以加入 img 操作吗?

是不是这个插件 只能缓存本地的图片 从后台请求过来的图片是不是不能做离线缓存?

`
module.exports = {
plugins:[

// 这个要放在前面就可以自动在 `<html>`标签中插入`manifest`属性
// This should be placed in the front can antomatically insert the `manifest` attribute in hte `<html>` tag
new HtmlWebpackPlugin({...}),
new Manifest({
    cache: [
      'js/[hash:8].sorting-index.js', 
      'css/[hash:8].sorting-test.css',
      'css/[hash:8].index-index.css'
    ],
    //Add time in comments.
    timestamp: true,
    // 生成的文件名字,选填
    // The generated file name, optional.
    filename:'cache.manifest', 
    // 注意*星号前面用空格隔开
    network: [
      'http://api.map.baidu.com/ *',
      'http://img.jslite.com/ *'
    ],
    // 注意中间用空格隔开
    fallback: ['/ /404.html'],
    // manifest 文件中添加注释
    // Add notes to manifest file.
    headcomment: pkg.name + " v" + pkg.version, 
    master: ['index/index.html']
})

]
}`


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

离线缓存要用 service worker, 可以用 google 这个库 https://developers.google.com...

分享一下我的做法,如何缓存远程资源,https://ostack.cn/a/1190000023803216


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share
...