如何避免来自IE 11中缓存的API数据响应?

时间:2018-12-05 10:02:18

标签: javascript html5 caching internet-explorer-11 browser-cache

我正在使用JavaScript进行API调用,但是第二次调用时,我是从缓存中获取数据的。

public class Foo {
  public static void main(String[] args) {
    System.out.println(getOldestVersion("12.18", "14.15"));
  }
  public static String getOldestVersion(String v1, String v2) {
    return Stream.of(v1.split("\\.")).mapToInt(Integer::parseInt).min().orElse(Integer.MAX_VALUE) > Stream.of(v2.split("\\.")).mapToInt(Integer::parseInt).min().orElse(Integer.MAX_VALUE)
        ? v2 : v1;
  }

  public static int parseInteger(String input) {
    return Integer.valueOf(input.replaceAll("\\D", ""));
  }
}

我已经在HTML的“标题”部分中添加了以上元标记。

并且在进行API调用时,我已经使用下面的标头来理解请求。

  <meta http-equiv="Cache-Control" content="no-cache" />  
  <meta http-equiv="expires" content="-1" />  
  <meta http-equiv="Pragma" content="no-cache" />

但是仍然第二次从缓存中获取该api数据。 此问题仅适用于IE。

除了下面提到的我也尝试过使用的标签

   { "Cache-Control" : "no-cache" , Pragma: "no-cache", Expires: "-1" }

但这无济于事。

任何人都可以提出解决方案的建议。

谢谢

1 个答案:

答案 0 :(得分:1)

在Internet Explorer 11中禁用网页缓存

如果在Internet Explorer 11中使用网页缓存,则StorageGRID Webscale Installer网页可能似乎无法正常工作。如果要使用此浏览器访问Installer网页,必须禁用缓存。

步骤 在Internet Explorer 11的右上角,单击齿轮图标齿轮图标。 从菜单中,选择“ Internet选项”。 在“常规”选项卡上,找到“浏览历史记录”部分,然后单击“设置”。 在“ Internet临时文件”选项卡上,确认已选中“每次我访问该网页”。 网站数据设置> Internet临时文件>每次访问所选网页时 在“缓存和数据库”选项卡上,确认未选中“允许网站缓存和数据库”。 网站数据设置>缓存和数据库>允许未选择的网站缓存 点击确定。