Page 1 of 1

ClearCache in Ram

Posted: Sun May 07, 2023 3:42 pm
by dilfich
Hi, as I understand it, "Network.clearBrowserCache" clears only what is on the disk, but how to completely clean it?

Experimentally found such a way out, but how much is it true? If you observe in devtools that with a similar approach, nothing loads from the ram cache anymore.

Code: Select all

     Chromium1.ExecuteDevToolsMethod(0, 'Network.enable', nil);

     TempParams := TCefDictionaryValueRef.New;
     TempParams.SetBool('cacheDisabled', True);
     Chromium1.ExecuteDevToolsMethod(0, 'Network.setCacheDisabled', TempParams);

     Chromium1.ClearDataForOrigin('');
     Chromium1.ClearCache;

     TempParams := TCefDictionaryValueRef.New;
     TempParams.SetBool('cacheDisabled', False);
     Chromium1.ExecuteDevToolsMethod(0, 'Network.setCacheDisabled', TempParams);

     Chromium1.ExecuteDevToolsMethod(0, 'Network.disable', nil);
This can be achieved manually in devtools, check the "disable cache" box, then clean the cache and uncheck the disable box.

Re: ClearCache in Ram

Posted: Tue May 09, 2023 9:16 am
by salvadordf
dilfich wrote: Sun May 07, 2023 3:42 pm Hi, as I understand it, "Network.clearBrowserCache" clears only what is on the disk, but how to completely clean it?
If clearing the cache in RAM is not working correctly then use a cache directory inside the temp directory given by System.IOUtils.TPath.GetTempPath

Then create a new browser with a new context that uses a different cache directory like :
C:\Users\<User name>\AppData\Local\Temp\cache001
C:\Users\<User name>\AppData\Local\Temp\cache002
C:\Users\<User name>\AppData\Local\Temp\cache003