建议加入一个缓存策略 #474
AuroraMaster
started this conversation in
Ideas
建议加入一个缓存策略
#474
Replies: 2 comments
-
有这个这计划,有兴趣可以给我提交PR |
Beta Was this translation helpful? Give feedback.
0 replies
-
请问这个计划启用了吗,我是在线打包的,有些网页需要缓存才能点击使用,所以就用不了 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Search before asking
I searched in the issues and found nothing similar.
Motivation
建议加入一个缓存策略,并在菜单栏加入update选项,在tauri.json 中设置缓存文件类型(html.htm.css.js.jpg、.jpeg、.png、.gif、.bmp.ttf、.otf、.woff、.woff2等),缓存时间,策略方式(优先本地,与网页比对后优先网页更新),我想这个功能对应用体验响应速度能起到很大帮助
Solution
这里有一个示例,但是需要rs配合,单独修改并不能正常使用
{
"build": {
"distDir": "dist",
"devPath": "http://localhost:3000",
"beforeBuild": [],
"afterBuild": [],
"publicPath": "./",
"watch": {
"debounce": 50,
"ignored": [
"node_modules//*",
"tauri//",
"dist/**/"
]
},
"cache": {
"enabled": true,
"types": [
"js",
"css",
"png",
"jpg",
"jpeg",
"gif",
"svg",
"woff",
"woff2",
"ttf",
"eot"
],
"strategy": "stale-while-revalidate",
"timeToLive": 3600
}
}
}
enabled:是否启用缓存,默认为false。
types:需要缓存的文件类型,可以是任何文件扩展名,如.js、.css、.png等。
strategy:缓存策略,可以是stale-while-revalidate、cache-first或network-first。
timeToLive:缓存时间,以秒为单位。
例如,上述代码中的缓存策略为stale-while-revalidate,表示在缓存过期后,仍然使用缓存文件,同时异步更新缓存文件。缓存时间为3600秒,即1小时。
Alternatives
No response
Anything else?
No response
Are you willing to submit a PR?
Beta Was this translation helpful? Give feedback.
All reactions