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.
Clear cache, history and form data while application running
Clear cache, history and form data while application running
Hi all!
i have found this as a big problem,
is there any way of clearing cache, history and all data that is inserted into web forms?
Thanks!
i have found this as a big problem,
is there any way of clearing cache, history and all data that is inserted into web forms?
Thanks!
- salvadordf
- Posts: 4564
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Clear cache, history and form data while application running
You can only clear the cookies while your app is running. If you need to delete the cache you can set GlobalCEFApp.DeleteCache to TRUE before the GlobalCEFApp.StartMainProcess call and CEF4Delphi will delete the cache before CEF is initialized.
If you really need to delete the cache while your app is running you can do this trick :
Create a new browser in your app that uses a new "request context". When you create the request context with the TCefRequestContextRef.New call you can assign a different cache directory in the first parameter. If the new cache directory is empty, it will have the same effect as if you cleared the cache at runtime for that browser.
For more details about creating new request contexts for each browser take a look at the MDIBrowser demo.
Edit : Just to clarify. When I said "empty" I meant a directory without files or other directories inside, not passing an empty cache parameter to TCefRequestContextRef.New.
If you really need to delete the cache while your app is running you can do this trick :
Create a new browser in your app that uses a new "request context". When you create the request context with the TCefRequestContextRef.New call you can assign a different cache directory in the first parameter. If the new cache directory is empty, it will have the same effect as if you cleared the cache at runtime for that browser.
For more details about creating new request contexts for each browser take a look at the MDIBrowser demo.
Edit : Just to clarify. When I said "empty" I meant a directory without files or other directories inside, not passing an empty cache parameter to TCefRequestContextRef.New.
Re: Clear cache, history and form data while application running
Thanks Salvador!
this is unfortunately getting way too complicated.
Isn't there really a way of clearing everything on refreshing?
Let's say if the browser is idle xx seconds, it will refresh itself and clear everything at the same time?
And why is that the following won't clear the history, cache and everything?
I have a timer which counts the idle time and does the refreshing but setting "no-cache" doesn't seem to do anything at all.
this is unfortunately getting way too complicated.
Isn't there really a way of clearing everything on refreshing?
Let's say if the browser is idle xx seconds, it will refresh itself and clear everything at the same time?
And why is that the following won't clear the history, cache and everything?
Code: Select all
{ - <<< - [ refresh the web page if idle for 3 minutes... ] - >>> - }
procedure TfrmMain.timerRefreshTimer(Sender: TObject);
begin
if frmRequired.labelIdleTime.Caption = '00:03:00' then
begin
{ clear history and cache }
chromiumMain.CustomHeaderName := 'Cache-Control';
chromiumMain.CustomHeaderValue := 'no-cache';
{ reload browser }
chromiumMain.LoadUrl(frmRequired.leditUserInterface.text);
{ close if on-screen keyboard is active }
if processExists('OnScreenKeyboard.exe') then
CloseOnScreenKeyboard;
end;
end;
- salvadordf
- Posts: 4564
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Clear cache, history and form data while application running
Try using TChromium.ReloadIgnoreCache to reload the web page ignoring the local cache contents in the TTimer.OnTimer event.
The Cache-Control:no-cache header indicates that the returned response can't be used to satisfy a subsequent request to the same URL without first checking with the server if the response has changed.
https://developers.google.com/web/funda ... tp-caching
The Cache-Control:no-cache header indicates that the returned response can't be used to satisfy a subsequent request to the same URL without first checking with the server if the response has changed.
https://developers.google.com/web/funda ... tp-caching
Re: Clear cache, history and form data while application running
Hi Salvador,
i need to reload it to the default page by ignoring the cache and history.
So,
How should i do it?
This is my default page and i need to ignore the cache and history while reloading it. When reloading is done, the browser is normally at somewhere else not at this default page.
"chromiumMain.LoadUrl(frmRequired.leditUserInterface.text);"
If i use only ReloadIgnoreCache, it reloads the page where it currently is.
So,
i need to reload this page "chromiumMain.LoadUrl(frmRequired.leditUserInterface.text" by ignoring the cache and history not the page where the application currently is.
How can i achieve this?
i need to reload it to the default page by ignoring the cache and history.
So,
How should i do it?
This is my default page and i need to ignore the cache and history while reloading it. When reloading is done, the browser is normally at somewhere else not at this default page.
"chromiumMain.LoadUrl(frmRequired.leditUserInterface.text);"
If i use only ReloadIgnoreCache, it reloads the page where it currently is.
So,
i need to reload this page "chromiumMain.LoadUrl(frmRequired.leditUserInterface.text" by ignoring the cache and history not the page where the application currently is.
How can i achieve this?
- salvadordf
- Posts: 4564
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Clear cache, history and form data while application running
First of all, sorry about the last link about the cache-control. That's meant for servers, not clients.
After researching this issue I found that adding the "Cache-Control: no-cache" request header is recommended by the CEF3 maintainer :
https://magpcss.org/ceforum/viewtopic.p ... 906#p37906
It's also suggested in the CEF sources :
https://bitbucket.org/chromiumembedded/ ... pes.h-1228
...and even other CEF wrapper maintainers suggest it as a solution for this issue. In this post he even suggests to add "Cache-Control: no-cache, no-store" :
https://magpcss.org/ceforum/viewtopic.p ... 966#p34148
Perhaps your server only supports HTTP/1.0. In that case you should add "Pragma: no-cache" to the request headers.
For more info, read this :
https://stackoverflow.com/questions/103 ... ol-headers
If everything fails, you still have 2 solutions :
After researching this issue I found that adding the "Cache-Control: no-cache" request header is recommended by the CEF3 maintainer :
https://magpcss.org/ceforum/viewtopic.p ... 906#p37906
It's also suggested in the CEF sources :
https://bitbucket.org/chromiumembedded/ ... pes.h-1228
...and even other CEF wrapper maintainers suggest it as a solution for this issue. In this post he even suggests to add "Cache-Control: no-cache, no-store" :
https://magpcss.org/ceforum/viewtopic.p ... 966#p34148
Perhaps your server only supports HTTP/1.0. In that case you should add "Pragma: no-cache" to the request headers.
For more info, read this :
https://stackoverflow.com/questions/103 ... ol-headers
If everything fails, you still have 2 solutions :
- Install a SSL certificate in your web server. Secure connections are not cached unless explicitly told otherwise.
- Create a second browser with a different cache directory in the new request context.
Re: Clear cache, history and form data while application running
Hi Salvador,
thank you for the response.
This is unfortunately not getting anywhere
Are you saying there is no way to clear the bloody cache and history of the browser?
Is this something which google ain't allowing us to do?
Google needs to know everything about our browser history right?
And how about this?
"If everything fails, you still have 2 solutions :
Install a SSL certificate in your web server. Secure connections are not cached unless explicitly told otherwise.
Create a second browser with a different cache directory in the new request context."
Seriously??
What SSL has got to do with clearing history of the browser?
What does change by creating a second browser with different cache directory?
I am not trying to save history, i am trying to prevent the cache and history.
thank you for the response.
This is unfortunately not getting anywhere

Are you saying there is no way to clear the bloody cache and history of the browser?
Is this something which google ain't allowing us to do?
Google needs to know everything about our browser history right?
And how about this?
"If everything fails, you still have 2 solutions :
Install a SSL certificate in your web server. Secure connections are not cached unless explicitly told otherwise.
Create a second browser with a different cache directory in the new request context."
Seriously??
What SSL has got to do with clearing history of the browser?
What does change by creating a second browser with different cache directory?
I am not trying to save history, i am trying to prevent the cache and history.
- salvadordf
- Posts: 4564
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Clear cache, history and form data while application running
I don't know if Google decided how this feature should work. I don't work for them.Hitman wrote: Wed Oct 31, 2018 9:13 am Are you saying there is no way to clear the bloody cache and history of the browser?
Is this something which google ain't allowing us to do?
Google needs to know everything about our browser history right?
Installing a SSL certificate makes your connection secure and those requests are not cached unless the server is configured to tell the browsers to cache all resources even on secure connections.
If you use a new browser with a different cache directory, your app will not be able to show any cached contents from the previous browser.Hitman wrote: Wed Oct 31, 2018 9:13 am What does change by creating a second browser with different cache directory?
I am not trying to save history, i am trying to prevent the cache and history.
It will behave exactly as if you deleted all the cache contents at runtime.
My previous message about adding the "Cache-Control: no-cache" request header meant that this is what usually works in your case.
Perhaps your app should add those headers to all requests or perhaps the server only supports HTTP/1.0.
I know that this is a complicated workaround to something that should be as easy as calling a "ClearCache" function and I understand your frustration.
If you really want that kind of function added to CEF3 you can always create a "pull request" in the CEF3 project with those code changes.
The CEF3 project maintainer often says that "PRs are welcome".
Re: Clear cache, history and form data while application running
Sorry!
i am still lost here!
Seriously?
aren't there any ways of preventing history and cache without doing all you are suggesting?
"My previous message about adding the "Cache-Control: no-cache" request header meant that this is what usually works in your case.
Perhaps your app should add those headers to all requests or perhaps the server only supports HTTP/1.0."
I already have "Cache-Control: no-cache" which doesn't seem to do anything at all.
Why is that there has to be history and cache anyway, why can't we decide either to have it or not?
What i am looking for is,
Disable the cache and history completely when my application starts for example, on FORMSHOW event or, restart the application if necessary in order to achieve zero history and zero cache.
Using SSL or server related things is not an option because we don't have a clue of what kind of server is used and we simply don't need to know about it at all, we are just running a html page where we insert personal data that should not be stored by the system at any point.
Creating a new browser ain't helping much either which will cause too much work and will still store the history and cache somewhere and will make things more complicated to control.
The goal is to prevent history and cache completely not to have a workaround of saving it in different ways.
i am still lost here!

Seriously?
aren't there any ways of preventing history and cache without doing all you are suggesting?
"My previous message about adding the "Cache-Control: no-cache" request header meant that this is what usually works in your case.
Perhaps your app should add those headers to all requests or perhaps the server only supports HTTP/1.0."
I already have "Cache-Control: no-cache" which doesn't seem to do anything at all.
Why is that there has to be history and cache anyway, why can't we decide either to have it or not?
What i am looking for is,
Disable the cache and history completely when my application starts for example, on FORMSHOW event or, restart the application if necessary in order to achieve zero history and zero cache.
Using SSL or server related things is not an option because we don't have a clue of what kind of server is used and we simply don't need to know about it at all, we are just running a html page where we insert personal data that should not be stored by the system at any point.
Creating a new browser ain't helping much either which will cause too much work and will still store the history and cache somewhere and will make things more complicated to control.
The goal is to prevent history and cache completely not to have a workaround of saving it in different ways.
- salvadordf
- Posts: 4564
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Clear cache, history and form data while application running
As far as I know, Chromium always uses a cache. You can configure it to be a local directory or in memory but it will always have a cache.Hitman wrote: Thu Nov 01, 2018 9:40 am aren't there any ways of preventing history and cache without doing all you are suggesting?
Have you tried "Cache-Control: no-cache, no-store" or "Pragma: no-cache"?Hitman wrote: Thu Nov 01, 2018 9:40 am I already have "Cache-Control: no-cache" which doesn't seem to do anything at all.
We can only decide if we want to use a local directory for the cache or "in-memory" cache. Not to disable it completely.Hitman wrote: Thu Nov 01, 2018 9:40 am Why is that there has to be history and cache anyway, why can't we decide either to have it or not?
Only the Chromium developer team can tell you why we can't disable it.
Yes, it's more complicated to implement but you have several demos that show you how to do it : MDIBrowser, TabbedBrowser, etc.Hitman wrote: Thu Nov 01, 2018 9:40 am What i am looking for is,
Disable the cache and history completely when my application starts for example, on FORMSHOW event or, restart the application if necessary in order to achieve zero history and zero cache.
Using SSL or server related things is not an option because we don't have a clue of what kind of server is used and we simply don't need to know about it at all, we are just running a html page where we insert personal data that should not be stored by the system at any point.
Creating a new browser ain't helping much either which will cause too much work and will still store the history and cache somewhere and will make things more complicated to control.
The goal is to prevent history and cache completely not to have a workaround of saving it in different ways.
Let's say you use the MDIBrowser as a template for your application and you create a new child browser associated to a new empty cache directory whenever your inactivity timer is triggered.
The old browser can be safely closed and its cache will never be used again. The new browser has a new empty cache, so your users will never see what the previous user did on the old browser.
If the problem is that a new user arrives before the inactivity timer is triggered then the web page should be modified to reset the form data when the old user leaves. Setting the autocomplete="off" attribute in all forms and inputs should help too.