Hexo使用EdgeOne接口实现自动化刷新缓存
Hexo使用EdgeOne接口实现自动化刷新缓存
青桔气球通过腾讯云SDK调用EdgeOne接口实现自动化刷新缓存。
- 首先你要安装腾讯云用于接口的SDK。执行以下命令:
1
npm install tencentcloud-sdk-nodejs
- Hexo根目录下新建EdgeOne.js文件,写入以下代码: 需要填写的字段有:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30javascriptconst tencentcloud = require("tencentcloud-sdk-nodejs-teo");
const TeoClient = tencentcloud.teo.v20220901.Client;
const clientConfig = {
credential: {
secretId: "xxxxxx",
secretKey: "xxxxxx",
},
region: "",
profile: {
httpProfile: {
endpoint: "teo.tencentcloudapi.com",
},
},
};
const client = new TeoClient(clientConfig);
const params = {
"ZoneId": "zone-xxxx",
"Type": "purge_host",
"Targets": [
"blog.qjqq.cn"
]
};
client.CreatePurgeTask(params).then(
(data) => {
console.log(data);
},
(err) => {
console.error("error", err);
}
);字段 是否填写 描述 secretId 是 密钥 secretKey 是 密钥 ZoneId 是 站点ID Type 是 purge_url:URL刷新 purge_prefix:目录刷新 purge_host:Hostname 刷新 purge_all:站点下全部缓存刷新 Targets 是 对应Type的刷新类型 - 完成上面这些操作,那么你就可以正式使用辣 你也可以组合使用比如Mac\Linux下:
1
node EdgeOne.js
1
hexo cl && hexo g && hexo d && node EdgeOne
评论
匿名评论隐私政策
✅ 你无需删除空行,直接评论以获取最佳展示效果





