每个浏览器有单独的缓存? [英] Separate cache per browser?

查看:258
本文介绍了每个浏览器有单独的缓存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,我将缓存路径设置如下:

Currently I'm setting the cache path as follows:

CefSettings settings = new CefSettings();
settings.CachePath = mycachePath;

Cef.Initialize(settings);

var browser = new ChromiumWebBrowser(myUrl);

以上方法有效。

但是,我需要同时登录具有2个不同帐户的网站,但是它使用相同的cookie容器。因此,如果我使用一个帐户登录,然后再使用另一个帐户登录,则第一个帐户将被覆盖。

However, I need to login to a website with 2 different accounts simultaneously but it uses the same cookie container. So if I login with one account and then the other, the first account is overridden.

每个浏览器是否有可能具有缓存路径?

Is it possible to have a have a cache path per browser?

还是有更好的方法来处理这种情况?

Or is there a better way to handle this situation?

推荐答案

您正在使用 CefSharp ?如果是这样,遍历代码,似乎您想使用空的 CachePath

It looks like you're using CefSharp? If so, looking through the code, it seems that you want to create the browser with an empty CachePath:

/// <summary>
/// Returns the cache path for this object. If empty an "incognito mode"
/// in-memory cache is being used.
/// </summary>
string CachePath { get; }

看着他们的样本(我假设没有窗户),这看起来大致上可以得到您想要的:

Looking at their sample (I'm assuming windowless), this looks like it'll get roughly what you want:

var browserSettings = new BrowserSettings();
var requestContextSettings = new RequestContextSettings { CachePath = "" };

using(var requestContext = new RequestContext(requestContextSettings))
using (var browser = new ChromiumWebBrowser(TestUrl, browserSettings, requestContext))
{
    ...
}

这篇关于每个浏览器有单独的缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆