简体   繁体   English

Aurelia Http fetch返回缓存数据

[英]Aurelia Http fetch returns cached data

So I am new to Aurelia and web development in general. 所以我是Aurelia和Web开发的新手。

Currently I have a view with a table of data. 目前我有一个数据表的视图。 After editing an entry and returning to the table I call my function to make another API call but instead my browser returns a 304 not modified (though in the database the values have been updated). 编辑一个条目并返回到表后,我调用我的函数进行另一个API调用,但我的浏览器返回304未修改(尽管在数据库中值已更新)。

When I enable "always refresh from server" in Edge I get the results as I would expect. 当我在Edge中启用“始终从服务器刷新”时,我会得到我期望的结果。 Is there some way of telling this Http request to always call the API and not from the cache? 有没有办法告诉这个Http请求始终调用API而不是缓存?

Off the top of my head, you could alter the url you're hitting to have some junk at the end of it. 在我的头顶,你可以改变你想要在它的末尾有一些垃圾的网址。

this.http.get(url + "?_t=" + new Date().getTime(), data).done(function(values) {
  //do stuff
});

Not pretty, but it should work. 不漂亮,但它应该工作。

Similarly, you could construct your own call to use. 同样,您可以构建自己的使用调用。

nonCachedGet(url, data) {
  return this.http.createRequest(url)
                  .asGet()
                  .withContent(data)
                  .withParams({ _t: new Date().getTime() })
                  .send();
}

It doesn't look like there are any specific settings telling the built in request methods not to cache, though. 但是,看起来没有任何特定的设置告诉内置请求方法不缓存。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM