Hi,
Here is what I've already manged to learn:
1. I know how to read and change "post data" ;
2. I know how to block some requests ;
3. I know how to read response data (obtained from server);
Question is:
How to block a request (that it never reach the server) but in the same time - give the response data from local cache.
I don't want to change the response from the server (this one I know how to do).
I want to "simulate" that request reached the server and came back with response. But the response is totally from my cache and server hasn't been used.
Do You have any idea how to acomplish this task ?
Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
How to prepare own cache for some requests ?
-
- Posts: 41
- Joined: Sun Feb 05, 2017 8:53 am
- salvadordf
- Posts: 4564
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: How to prepare own cache for some requests ?
I've never done that but it should be possible if you use the TChromium.OnBeforeResourceLoad and modify the flags in the request.
The flags should be set like this :
The flags should be set like this :
Code: Select all
request.flags := request.flags or UR_FLAG_ONLY_FROM_CACHE;
-
- Posts: 41
- Joined: Sun Feb 05, 2017 8:53 am
Re: How to prepare own cache for some requests ?
Salvador,
I found the solution. And You have done this (providing local data for request) in CRBrowser demo
.
I used the TCustomResourceHandler and for some requests in "response filter" I write data to cache. And than when the new request wants the same path I just provide data from memory in "onGetResourceHandler". And it works. Of course in DevTools I can see that response header is not exactly perfect, but result=200 makes it working fine. Who cares about response header
.
I found the solution. And You have done this (providing local data for request) in CRBrowser demo

I used the TCustomResourceHandler and for some requests in "response filter" I write data to cache. And than when the new request wants the same path I just provide data from memory in "onGetResourceHandler". And it works. Of course in DevTools I can see that response header is not exactly perfect, but result=200 makes it working fine. Who cares about response header
