Set CachePath in CefSharp

12,305

Solution 1

For an example of setting CachePath see here:

https://github.com/cefsharp/CefSharp/blob/v39.0.2/CefSharp.Example/CefExample.cs#L32

Solution 2

public ChromiumWebBrowser browser;

private void Form1_Load(object sender, EventArgs e)
{

    var newsettings = new BrowserSettings();

    CefSettings Settings = new CefSettings();
    Settings.CachePath = "test";  //always set the cachePath, else this wont work

    //add an if statement to initialize the settings once. else the app is going to crash
     if (CefSharp.Cef.IsInitialized == false)
         CefSharp.Cef.Initialize(Settings);

    var browser = new ChromiumWebBrowser(url) { Dock = DockStyle.Fill };

     toolStripContainer1.ContentPanel.Controls.Add(browser);
}
Share:
12,305
user1438823
Author by

user1438823

Updated on June 04, 2022

Comments

  • user1438823
    user1438823 almost 2 years

    I have set up CefSharp and built with a embedded URL using the help of this tutorial. But I do not know how to set the CachePath properly. There are about 12 modules in the project. I want my cache files to be persisted and when next time user loads the browser it should not take much time.