Caching Jquery Ajax request in Cache webworker

  axios, browser-cache, caching, javascript, jquery

I am working in an application where legacy code and newer one are coexisting.

In the legacy code, the API requests are done with Jquery Ajax, and in the new one, with axios.

I would like to have browser cache between calls in the two cases, because there are calls that are done in both ways, jquery and axios

I would like to use the Cache webworkers approach, as it’s the more browser standard and I don’t need any comunication, between the two parts

The problem is that I can’t change the legacy to remove the JQuery approach, so I need to keep doing the calls with JQuery, so the cache.add() method is discarted.

I was thinking in using cache.put, as it doesn’t needs to make the call, I only need to store the request and the response, but in JQuery, the request is not a Request object that I can store, and if I store only the URL, it can have problems because I can store verbs or body params, so I think that it can have problems with calls with different body params.

Anyone can give me any tips about how to implement this? or should I just give up on this solution and move to something custom made?


Source: Ask Javascript Questions