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.
History and cache
History and cache
Hi guys,
could someone please help me with this?
I need to be able to clear cache, history, form data, everything from the browser.
I have a refresh button where i would like to place my code to clear everything after each use.
How this is done?
Many thanks in advance
could someone please help me with this?
I need to be able to clear cache, history, form data, everything from the browser.
I have a refresh button where i would like to place my code to clear everything after each use.
How this is done?
Many thanks in advance
- salvadordf
- Posts: 4564
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: History and cache
Hi,
CEF doesn't allow to delete the cache files while the browser is running but you can set GlobalCEFApp.DeleteCache and GlobalCEFApp.DeleteCookies to TRUE before calling GlobalCEFApp.StartMainProcess to delete the cache and cookies just before CEF is initialized.
Your app can save a registry value, INI value or whatever you like. The next time your app is executed it will read that value and set GlobalCEFApp.DeleteCache and GlobalCEFApp.DeleteCookies.
CEF doesn't allow to delete the cache files while the browser is running but you can set GlobalCEFApp.DeleteCache and GlobalCEFApp.DeleteCookies to TRUE before calling GlobalCEFApp.StartMainProcess to delete the cache and cookies just before CEF is initialized.
Your app can save a registry value, INI value or whatever you like. The next time your app is executed it will read that value and set GlobalCEFApp.DeleteCache and GlobalCEFApp.DeleteCookies.
Re: History and cache
Hi!
thanks a lot!
how this is done?
any samples?
Best regards
thanks a lot!
how this is done?
any samples?
Best regards
- salvadordf
- Posts: 4564
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: History and cache
Read these pages to use INI files and the registry :
http://docwiki.embarcadero.com/RADStudi ... MemIniFile
http://docwiki.embarcadero.com/RADStudi ... _TRegistry
The simplest DPR code to delete the cache and cookies would be :
MustDeleteCache would be a custom function that reads the registry or the INI file.
http://docwiki.embarcadero.com/RADStudi ... MemIniFile
http://docwiki.embarcadero.com/RADStudi ... _TRegistry
The simplest DPR code to delete the cache and cookies would be :
Code: Select all
program Project1;
uses
Vcl.Forms,
WinApi.Windows,
uCEFApplication,
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
{$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE}
begin
GlobalCEFApp := TCefApplication.Create;
if MustDeleteCache then
begin
GlobalCEFApp.DeleteCache := True;
GlobalCEFApp.DeleteCookies := True;
end;
if GlobalCEFApp.StartMainProcess then
begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TForm1, Form1);
Application.Run;
end;
GlobalCEFApp.Free;
end.
Re: History and cache
Hi!
thank you.
I know how to create and use ini files but not sure what the ini file has got to do with the history and cache of the browser.
The goal is to prevent browser creating history and cache.
So what i am saying is,
no history, no cache at all.
Is there any samples of how to prevent browser from collecting history and cache?
About this code,
shouldn't i be okay if i add the following lines to my own DPR?
{ if MustDeleteCache then
begin
GlobalCEFApp.DeleteCache := True;
GlobalCEFApp.DeleteCookies := True;
end; }
I have a "Refresh" button and "Back" button in my app, i would like to be able to clear up everything when one of these buttons clicked.
thank you.
I know how to create and use ini files but not sure what the ini file has got to do with the history and cache of the browser.
The goal is to prevent browser creating history and cache.
So what i am saying is,
no history, no cache at all.
Is there any samples of how to prevent browser from collecting history and cache?
About this code,
shouldn't i be okay if i add the following lines to my own DPR?
{ if MustDeleteCache then
begin
GlobalCEFApp.DeleteCache := True;
GlobalCEFApp.DeleteCookies := True;
end; }
I have a "Refresh" button and "Back" button in my app, i would like to be able to clear up everything when one of these buttons clicked.
- salvadordf
- Posts: 4564
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: History and cache
I mention them in case you wanted to add a "clear cache" function in your app. That function would set a custom value value in the ini or the registry that your app would read next time it runs to set GlobalCEFApp.DeleteCache and GlobalCEFApp.DeleteCookies to true.Hitman wrote: Fri Apr 20, 2018 1:12 pm Hi!
thank you.
I know how to create and use ini files but not sure what the ini file has got to do with the history and cache of the browser.
This way your app would use a cache in the users hard drive but your app or the user could clear it the next it executes your app.
That's even easier!Hitman wrote: Fri Apr 20, 2018 1:12 pm The goal is to prevent browser creating history and cache.
So what i am saying is,
no history, no cache at all.
Is there any samples of how to prevent browser from collecting history and cache?

Just leave GlobalCEFApp.cache and GlobalCEFApp.cookies blank.
All the demos use the default (empty) values GlobalCEFApp.cache and GlobalCEFApp.cookies. This way CEF uses "in memory" cache.
The refresh button could call TChromium.ReloadIgnoreCache to download the web page ignoring the cached resources.Hitman wrote: Fri Apr 20, 2018 1:12 pm About this code,
shouldn't i be okay if i add the following lines to my own DPR?
{ if MustDeleteCache then
begin
GlobalCEFApp.DeleteCache := True;
GlobalCEFApp.DeleteCookies := True;
end; }
I have a "Refresh" button and "Back" button in my app, i would like to be able to clear up everything when one of these buttons clicked.
You can also set HTTP headers to download all the resources again. If I remember correctly, you would have to set TChromium.CustomHeaderName with "Cache-Control" and TChromium.CustomHeaderValue with "no-cache".
Re: History and cache
Okay,
many thanks!
please clear me up,
"Just leave GlobalCEFApp.cache and GlobalCEFApp.cookies blank."
As far as i know,
i am not asking for any cache or cookies or history while running the browser, it keeps all by itself
How do i leave them blank?
do you mean i should not add the following code to my DPR at all?
{if MustDeleteCache then
begin
GlobalCEFApp.DeleteCache := True;
GlobalCEFApp.DeleteCookies := True;
end;}
I am already using this and it has no effect
TChromium.ReloadIgnoreCache
It still brings the data inserted into the web form.
All i want to do is to prevent it bringing any previously inserted data back.
many thanks!
please clear me up,
"Just leave GlobalCEFApp.cache and GlobalCEFApp.cookies blank."
As far as i know,
i am not asking for any cache or cookies or history while running the browser, it keeps all by itself

How do i leave them blank?
do you mean i should not add the following code to my DPR at all?
{if MustDeleteCache then
begin
GlobalCEFApp.DeleteCache := True;
GlobalCEFApp.DeleteCookies := True;
end;}
I am already using this and it has no effect

TChromium.ReloadIgnoreCache
It still brings the data inserted into the web form.
All i want to do is to prevent it bringing any previously inserted data back.
- salvadordf
- Posts: 4564
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: History and cache
Hitman wrote: Fri Apr 20, 2018 2:16 pm Okay,
many thanks!
please clear me up,
"Just leave GlobalCEFApp.cache and GlobalCEFApp.cookies blank."
As far as i know,
i am not asking for any cache or cookies or history while running the browser, it keeps all by itself![]()
How do i leave them blank?
Code: Select all
GlobalCEFApp.cache := '';
GlobalCEFApp.cookies := '';
You don't need that if you don't use a disk cache.Hitman wrote: Fri Apr 20, 2018 2:16 pm do you mean i should not add the following code to my DPR at all?
{if MustDeleteCache then
begin
GlobalCEFApp.DeleteCache := True;
GlobalCEFApp.DeleteCookies := True;
end;}
I tried to replicate this in MiniBrowser and the form fields don't keep the previous values. I tried these websites :Hitman wrote: Fri Apr 20, 2018 2:16 pm I am already using this and it has no effect![]()
TChromium.ReloadIgnoreCache
It still brings the data inserted into the web form.
All i want to do is to prevent it bringing any previously inserted data back.
https://www.w3schools.com/php/php_form_complete.asp
http://www.echoecho.com/htmlforms01.htm
Perhaps you can avoid that problem if you use a SSL certificate in your web server.
Re: History and cache
Do you use the following?
TChromium.ReloadIgnoreCache
TChromium.ReloadIgnoreCache
- salvadordf
- Posts: 4564
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: History and cache
I used MiniBrowser without modifications which uses TChromium.Reload but I just tested those web pages again calling TChromium.ReloadIgnoreCache and I still can't replicate this issue. The form values are cleared after reloading using TChromium.ReloadIgnoreCache or TChromium.Reload.
Please try the MiniBrowser demo, click on the top-right button and select "Preferences". Then type "Cache-Control" without quotes in the Name edit box and "no-cache" without quotes in the Value edit box. Click OK and visit any website. It will download all resources ignoring the cache and the form values are cleared even when you click the "left" and "right" navigation buttons.
Please try the MiniBrowser demo, click on the top-right button and select "Preferences". Then type "Cache-Control" without quotes in the Name edit box and "no-cache" without quotes in the Value edit box. Click OK and visit any website. It will download all resources ignoring the cache and the form values are cleared even when you click the "left" and "right" navigation buttons.