1

I have an Aurelia app using HttpFetch from aurelia-fetch-client v1.8.2. The problem I'm experiencing is that the Chrome browser is caching some GET request URLs between my deployments.

E.g. one particular request would go to .../api/v1/users but has since been changed to .../api/v1/users?somequerystring=value, however clients are reporting that the old URL is still being used. It's happening to about 3/4 users. For some reason myself and a small handful of users work correctly and requests are made using the updated GET URL.

I've experienced response caching in the past before and have since added '?cacheBust=' + new Date().getMilliseconds() to every GET URL request to ensure uniqueness, however this new type of caching is unfamiliar to me.

It's worth noting that this may be some JS file caching as the users are seeing the updated front-end pages.

Having the developer console open and performing an Empty Cache and Hard Reload obviously works, but I can expect my users to need to do that whenever I update the request URLs.

Any suggestions?

JP Damstra
  • 545
  • 7
  • 25
  • Nice issue you ran into there. Under the hood, it's still the same technique that you mentioned there: cache bursting via a query parameter. Maybe if you want, create a PR to add a config to be able to burst the cache? – bigopon Jun 04 '20 at 07:46
  • 1
    are you sure the caching is done on the `get` request `url`? it's more likely that your application code is cached in the client browser. you should configure your server to serve the `index.html` page with no caching. and then - whenever you update your code. all users will get the new version. (webpack, require etc. do apply cache busting mechanizem to the bundles they create) – avrahamcool Jun 04 '20 at 08:10

1 Answers1

0

As you yourself mentioned, as well as a comment, please check to see if it's not just a .JS file being improperly cached.

That being said, in case you're confident that it's related to the fetch client, or remote calls, you might want to look in the Request.cache property of the native fetch() API. Considering the aurelia-fetch-client library is just a wrapper around this native API, you might try something like:

const response = await _http.fetch('endpoint', { cache: 'no-store' });

There are lots of more examples in the referenced link to the docs. But in a nutshell, the no-store option tells the browser to get the resource from the remote server without first looking in the cache.

Juliën
  • 9,047
  • 7
  • 49
  • 80