在使用标准配置安装RestBase之后,我有一个工作版的摘要API。
缓存机制对我来说似乎很奇怪的问题。这段代码将决定是否查看表缓存以获得快速响应。但我不能使它成为服务器缓存依赖于一些时间约束(例如,当写入缓存时的max-age)。这意味着使用缓存的决定完全取决于客户端。
有人可以解释RestBase缓存机制的工作流程吗?
// Inside key.value.js
getRevision(hyper, req) {
//This one get the header from client request and decide to use cache
or not depend on the value. Does it mean server caching is non-existent?
if (mwUtil.isNoCacheRequest(req)) {
throw new HTTPError({ status: 404 });
}
//If should use cache, below run
const rp = req.params;
const storeReq = {
uri: new URI([rp.domain, 'sys', 'table', rp.bucket, '']),
body: {
table: rp.bucket,
attributes: {
key: rp.key
},
limit: 1
}
};
return hyper.get(storeReq).then(returnRevision(req));
}
缓存失效由change propagation service完成,Varnish在页面编辑和类似事件上触发。缓存控制头可能在here VCL逻辑中设置。有关完整的维基媒体基础图,请参阅qazxswpoi - 它已过时,但为您提供了如何将事物连接在一起的通用概念。