Caching Http Requests #110
Replies: 1 comment
|
I just use traffic_recorder.pyfrom future import annotations from patchright.async_api import BrowserContext, Request as PwRequest, Response as PwResponse _JSON = Union[dict, list, str, int, float, bool, None] @DataClass class RequestHistory: async def _lowered_headers(headers: Dict[str, str]) -> Dict[str, str]: def _headers_contains( def _json_matches(root: _JSON, expected: Dict[str, Any]) -> bool: _index_re = re.compile(r"(.+)[(\d+)]$") def _json_get(root: _JSON, path: str) -> Any: self.traffic = RequestHistory( |
Uh oh!
There was an error while loading. Please reload this page.
Caching does not seem to work
My setup
page.routeorcontext.route. Saw that there was an issue with this in caching, but I do not implement it.The Issue
When using an ordinary browser, I get
200 OK (from memory cache)and thex-cache: RefreshHit from cloudfrontOn the patchright controlled environment, I get
200 OKbut thex-cacheheader is non -existent in most staticly served files.The result, the page takes forever to reload
Diagnosis
Tried to run the proxy server across a normal browser without playwright and the result was as expected, caching was working fine hence ruling out the effects of the proxy server
Tried to change a couple of default injected args when running chrome, nothing worked
Below is the setup code I used, also to add, I was testing the ignore-default-args one by one. The script below showcases all the arguments I tested.
My thought process
Something in either playwright or patchright may be causing the problem. Any assistance will be appreciated
All reactions