segment-boneyard / nightmare

A high-level browser automation library.
https://open.segment.com
19.55k stars 1.08k forks source link

log shows caching is possibly not happening #1118

Closed elderbas closed 7 years ago

elderbas commented 7 years ago

I think I'm either I'm understanding the log message incorrectly or I'm not using cache.

From running my nightmarejs script, as I crawl across the website, I think I'm seeing this same CSS file getting requested multiple times (the same nightmare log across different pages). Is it requesting the same file multiple times from the server, or am I reading it wrong?

DEBUG=* node myScript.js
...
...
nightmare:log did-get-response-details [{},false,"http://someBaseUrl/footer.css","http://someBaseUrl/footer.css",200,"GET","<someUrl>",{"accept-ranges":["bytes"],"cache-control":["max-age=300"],"content-encoding":["gzip"],"content-length":["403"],"content-type":["text/css"],"date":["Sat, 29 Apr 2017 13:51:27 GMT"],"etag":["\"3fc-51a4872f8d5d2\""],"expires":["Sat, 29 Apr 2017 13:56:27 GMT"],"last-modified":["Thu, 09 Mar 2017 09:02:59 GMT"],"server":["Apache"],"vary":["Accept-Encoding"],"x-frame-options":["SAMEORIGIN"],"stylesheet"]
... (some other page)
nightmare:log did-get-response-details [{},false,"http://someBaseUrl/footer.css","http://someBaseUrl/footer.css",200,"GET","<someUrl>",{"accept-ranges":["bytes"],"cache-control":["max-age=300"],"content-encoding":["gzip"],"content-length":["403"],"content-type":["text/css"],"date":["Sat, 29 Apr 2017 13:51:27 GMT"],"etag":["\"3fc-51a4872f8d5d2\""],"expires":["Sat, 29 Apr 2017 13:56:27 GMT"],"last-modified":["Thu, 09 Mar 2017 09:02:59 GMT"],"server":["Apache"],"vary":["Accept-Encoding"],"x-frame-options":["SAMEORIGIN"],"stylesheet"]
casesandberg commented 7 years ago

There currently isnt a way to do this. Do you have some time to throw together a PR? I would be happy to take a look at it. I am going to close this, but feel free to open a new issue if you get a chance to work on it.