Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Api Github中的图像缓存?_Api_Github_Caching - Fatal编程技术网

Api Github中的图像缓存?

Api Github中的图像缓存?,api,github,caching,Api,Github,Caching,GitHub中是否有图像的缓存策略 从API渲染图像时遇到问题。当我在浏览器中打开图像时,它工作正常 但是,Github渲染该图像的一些旧版本 我如何解决这个问题,或者是否有任何修复方法?考虑到,可能添加ts=$(日期)作为a的参数就足够满足您的需要了 从代码中: const cacheBuster = new Date().getTime(); const params = [`ts=${cacheBuster}`]; if (options.params) { for (const ke

GitHub中是否有图像的缓存策略
从API渲染图像时遇到问题。当我在浏览器中打开图像时,它工作正常
但是,Github渲染该图像的一些旧版本

我如何解决这个问题,或者是否有任何修复方法?

考虑到,可能添加
ts=$(日期)
作为a的参数就足够满足您的需要了

从代码中:

const cacheBuster = new Date().getTime();
const params = [`ts=${cacheBuster}`];
if (options.params) {
  for (const key in options.params) {
    params.push(`${ key }=${ encodeURIComponent(options.params[key]) }`);
  }
}
if (params.length) {
  path += `?${ params.join("&") }`;
}
return this.api_root + path;

这会将
&ts=xxx
时间戳参数添加到
api.github.com
调用中。

github可以主动缓存图像(特别是徽章)。看:你能建议一些解决方法吗?这样图像也会在那里更新吗?是的,如果您自己托管图像,您需要一个web服务器,该服务器允许设置HTTP响应头,如上面的链接中所述。所以我们基本上是在为每个请求获取一个新的唯一URL。@PraveenKumar Yes,一种经典的缓存破坏技术。