Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set CachePath in CefSharp

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.

like image 257
user1438823 Avatar asked May 19 '26 15:05

user1438823


2 Answers

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);
}
like image 106
chosenOne Thabs Avatar answered May 22 '26 04:05

chosenOne Thabs


For an example of setting CachePath see here:

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

like image 40
jornh Avatar answered May 22 '26 06:05

jornh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!