如何使Phantom.js像普通浏览器一样缓存资源? [英] How do I make Phantom.js cache resources like a normal browser?
问题描述
Chrome不会在每次请求时都重新下载javascript文件.他们将其缓存.
但是,当我的Phantom.js点击页面时,它每次都会下载javascript.是否有可以使它像浏览器一样工作的设置?
PhantomJs已经支持内存中缓存;这意味着,如果您在同一个正在运行的实例中浏览多个页面,PhantomJs将不会下载缓存中已经存在的资源.
您可以打开磁盘缓存;这会将Web资源(js,css,图像等)存储在物理磁盘中.
这由命令行参数控制:
-
磁盘缓存 = [true | false]启用磁盘缓存(在桌面服务缓存存储位置,默认为false).也接受:[是|否]
-
max-disk-cache-size = size限制磁盘缓存的大小(以KB为单位).
通过此链接,它似乎存储在Windows的%AppData%/Local/Ofi Labs/PhantomJS/cache/http.
下. /p>
Chrome doesn't re-download javascript files every request. They cache it.
However, when my Phantom.js hits pages, it downloads the javascript every single time. Is there a setting that can make this act like a browser?
PhantomJs already supports in-memory cache ; this means that if you browse multiple pages in side the same running instance, PhantomJs will not download resources already in the cache.
You could turn on disk cache ; this will store web resources (js, css, images, ...) in the physical disk.
This is controlled by a command line parameter :
disk-cache=[true|false] enables disk cache (at desktop services cache storage location, default is false). Also accepted: [yes|no]
max-disk-cache-size=size limits the size of disk cache (in KB).
From this link, it seems to be stored under %AppData%/Local/Ofi Labs/PhantomJS/cache/http.
on windows.
这篇关于如何使Phantom.js像普通浏览器一样缓存资源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!