0

I'm trying to implement a feature in an extension I'm building that consists of "manually" caching requests. It's for a website that has a search box that takes around 15 seconds (when it doesn't timeout) every time I search for something and never caches anything. What I pretend to do is store the response JSON in localStorage and return it when the request is made (updating it daily on the background). I got to the conclusion that it can't be made using the webRequests API and the best way to achieve it is by modifying the XMLHttpRequest prototype, but how can I do it?

I've tried to modify the send method on the XHR prototype and adding a readystatechange event listener to return the "cached" response when readyState == 2, but I have no idea how to actually return my own response. Thanks in advance!

0 Answers0