Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.

ClearCache in Ram

Post Reply
dilfich
Posts: 330
Joined: Thu Nov 30, 2017 1:17 am

ClearCache in Ram

Post 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.
User avatar
salvadordf
Posts: 4056
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: ClearCache in Ram

Post 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
Post Reply