Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Aurelia Http fetch returns cached data

So I am new to Aurelia and web development in general.

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).

When I enable "always refresh from server" in Edge I get the results as I would expect. Is there some way of telling this Http request to always call the API and not from the cache?

like image 790
Justin Avatar asked Sep 27 '22 22:09

Justin


1 Answers

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.

like image 157
Ixonal Avatar answered Oct 03 '22 02:10

Ixonal