Need a method to clear the cache

Think CEF could benefit from a new feature or capability? Discuss CEF feature requests here.

Need a method to clear the cache

Postby arabesc » Mon Apr 25, 2011 7:55 am

Need a method to clear the CEF cache.
And a possibility to set the maximum cache size would be the good feature too.
arabesc
Techie
 
Posts: 16
Joined: Sun Apr 17, 2011 4:37 pm
Location: Moscow.ru

Re: Need a method to clear the cache

Postby magreenblatt » Tue Apr 26, 2011 1:06 pm

Need a method to clear the CEF cache.

There are a few options that work currently.

1. Bypass the cache on page reload by using CefBrowser::ReloadIgnoreCache().
2. Clear the cache when CEF exists by using in-memory cache or by deleting the cache_path directory after CEF exits.
3. Use one of various standard techniques for bypassing caching: http://www.google.com/?q=bypass+cache

And a possibility to set the maximum cache size would be the good feature too.

Are you experiencing a particular problem? See BackendImpl::AdjustMaxCacheSize in src/net/disk_cache/backend_impl.cc for an idea of how cache size is currently calculated.
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm

Re: Need a method to clear the cache

Postby arabesc » Tue Apr 26, 2011 1:59 pm

magreenblatt wrote:2. Clear the cache when CEF exists by using in-memory cache or by deleting the cache_path directory after CEF exits.

It's a simple and logical solution.
But it would be a better solution to have an opportunity to clear cache without shutting CEF down. It's not always convinient to do so while the application is still running.
To clarify: the main idea is to free disk space while the application is running.

Are you experiencing a particular problem?

No, just want to give users more flexible controls.
arabesc
Techie
 
Posts: 16
Joined: Sun Apr 17, 2011 4:37 pm
Location: Moscow.ru

Re: Need a method to clear the cache

Postby magreenblatt » Tue Apr 26, 2011 2:18 pm

arabesc wrote:
magreenblatt wrote:2. Clear the cache when CEF exists by using in-memory cache or by deleting the cache_path directory after CEF exits.

It's a simple and logical solution.
But it would be a better solution to have an opportunity to clear cache without shutting CEF down. It's not always convinient to do so while the application is still running.
To clarify: the main idea is to free disk space while the application is running.

Are you experiencing a particular problem?

No, just want to give users more flexible controls.

What cache(s) are you interested in clearing? There are quite a few -- page, history, cookies, HTML5 storage (local, session, database), JavaScript, etc. Clearing some of these caches while an application is running could have strange results.
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm

Re: Need a method to clear the cache

Postby arabesc » Tue Apr 26, 2011 2:51 pm

magreenblatt wrote:What cache(s) are you interested in clearing? There are quite a few -- page, history, cookies, HTML5 storage (local, session, database), JavaScript, etc.

Just all of them. All content that have placed on the cef_settings_t::cache_path. Maybe except cookies. It's not critical. There is an opportunity to remove cookies through the CefCookieVisitor::Visit method.
arabesc
Techie
 
Posts: 16
Joined: Sun Apr 17, 2011 4:37 pm
Location: Moscow.ru

Re: Need a method to clear the cache

Postby JRub » Fri Oct 12, 2012 7:53 am

Hello,

Is there a clean way of clearing HTTP session data?
I need to be able to remove session data on an on-demand basis without exiting CEF.
CEF 3.1453.1255 on Windows 7 32bits
JRub
Mentor
 
Posts: 92
Joined: Wed Sep 19, 2012 8:32 am
Location: Paris, France

Re: Need a method to clear the cache

Postby bioncube » Wed Jan 30, 2013 8:56 pm

JRub wrote:Hello,

Is there a clean way of clearing HTTP session data?
I need to be able to remove session data on an on-demand basis without exiting CEF.


Did you find a good way to achieve this?
bioncube
Techie
 
Posts: 43
Joined: Wed Oct 03, 2012 7:03 am

Re: Need a method to clear the cache

Postby JRub » Fri Feb 08, 2013 7:18 am

bioncube wrote:
JRub wrote:Hello,

Is there a clean way of clearing HTTP session data?
I need to be able to remove session data on an on-demand basis without exiting CEF.


Did you find a good way to achieve this?

No.
I can remove session cookies with the cookie visitor, but nothing more.
CEF 3.1453.1255 on Windows 7 32bits
JRub
Mentor
 
Posts: 92
Joined: Wed Sep 19, 2012 8:32 am
Location: Paris, France

Re: Need a method to clear the cache

Postby ender » Sun Apr 27, 2014 5:57 am


Is there a clean way of clearing HTTP session data?
I need to be able to remove session data on an on-demand basis without exiting CEF.


Did you find a good way to achieve this?

No.
I can remove session cookies with the cookie visitor, but nothing more.


thanks above.

well.
because session also actually base on cookies. so,if we just clear cookies ,then session is also empty.
i have just achieve it .



Code: Select all
 

   CefCookieManager.Global.VisitAllCookies(new CefCookieVisitorImp());


   public class CefCookieVisitorImp : CefCookieVisitor {
        protected override bool Visit(CefCookie cookie, int count, int total, out bool delete) {
            delete = true;
          //  Console.WriteLine(cookie.Domain + " " + cookie.Name + " " + cookie.Value);

            return true;
        }
    }

ender
Newbie
 
Posts: 1
Joined: Sun Apr 27, 2014 5:29 am

Re: Need a method to clear the cache

Postby mistymorning » Mon May 12, 2014 9:39 am

I had this trouble plus trouble when calling CefRuntime.Shutdown() popping up an error message and also removing .ico files used by the forms images needed for bookmarks

The way that I solved all three problems was to write a little app and call the app with the processID for the browser and first kill the browser process and then delete the icon files plus the cache using this code

Code: Select all
using System;
using System.Diagnostics;
using System.IO;
using System.Windows.Forms;
using System.Threading;

namespace MistyMorningClearHistory
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main(string[] args)
        {

            string AppPath = Application.StartupPath + "\\";
            if (args.Length == 0)
            {
                MessageBox.Show("No arguments to clear folder");
                return;
            }

            bool DeleteCache = bool.Parse(args[0]);
            bool DeleteIcons = bool.Parse(args[1]);
            int ProcessID = int.Parse(args[2]);
            Thread.Sleep(100);
            if (ProcessID > 0)
            {
                try
                {
                    Process P = Process.GetProcessById(ProcessID);
                    P.Kill();
                }
                catch { ;}
            }
            Thread.Sleep(600);
            if (DeleteIcons) ClearHistory(AppPath + "Icons", 0, false);
            if (DeleteCache) ClearHistory(AppPath + "Cache", 0, false);
        }

        public static void ClearHistory(string Path, int Depth, bool IncludeLog)
        {//Chance some of the files are locked
            DirectoryInfo DInfo = new DirectoryInfo(Path);
            foreach (FileInfo FInfo in DInfo.GetFiles())
            {
                if (IncludeLog || FInfo.Name.ToLower() != "debug.log")//We delete this file on start-up
                { try { FInfo.Delete(); } catch { ;} }
            }
            foreach (DirectoryInfo DInfoSub in DInfo.GetDirectories())
            {
                ClearHistory(DInfoSub.FullName, Depth + 1, IncludeLog);
            }
            if (Depth > 1) try { DInfo.Delete(); }
                catch { ;}
        }

    }
}


Yes as dirty as sin but it's the only way I found to get it to work
Building a web-browser that does not call home
mistymorning
Techie
 
Posts: 15
Joined: Sun May 04, 2014 8:08 am


Return to Feature Request Forum

Who is online

Users browsing this forum: No registered users and 23 guests