TMSFNCWebBrowser cache folder

How to change cache folder name in the TMSFNCWebBrowser?
I tried to change it using the code below:

:
TMSFNCWebBrowser1.CacheFolderName:='W:\Temp\Cache';
TMSFNCWebBrowser1.Initialize;
:

I checked that the “CacheFolderName” property has the new folder name, but the files are still saved in the default folder.

Hi,

We are currently working on a new version that will allow you to set a custom cache folder. The CacheFolderName is only the name part of the folder, it will still be generated in the temp directory.

I would like that component don't delete the cache folder at the end of the application and restart it using the cache from the previous session (if available).

Can you create a configuration to keep / use files from the previous cache?

Thank you.

Yes, We are changing the behavior. There will be an AutoClearCache and CacheFolder property. As well as a ClearCache method to manually clear the cache. The AutoClearCache can then be set to False to ensure the cache is not cleared when closing the form. The next version will address this. I have sent you an incremental source update that should allow doing this. (check your private messages)

The AutoClearCache:= False property was what I needed. THANK YOU ! :slight_smile:

I hope that the option to change the cache folder will be available soon.

Another question: is there an event that is triggered when changes occur on the displayed page? I need something like an OnPageChange or OnTextOnPageUpdade event that fires if any text or image on the page is changed.

Thank you.

Hi,

With the incremental source update that I've sent you, you should be able to set the cache folder with the property:

TMSFNCWebBrowser1.CacheFolder := 'C:\temp\MyCache';

and the name of the folder that is created as a subfolder

TMSFNCWebBrowser1.CacheFolderName := 'MyCacheFolder';

This way you can have more than one instance with the same cache folder but different cache names.
There will be a cache folder for every instance of TTMSFNCWebBrowser.

For the question on the changes event, can you provide more in detail about what exactly you want to achieve? The OnNavigateComplete event is triggered for every navigation change. There is no detection mechanism for dynamic changes on the page.

I changed the cache folder but it continues to be created in the folder:
{EXE_FOLDER}{EXE_NAME}_WebView2

Example:
W:\Windows_Temp\web\Win32\Debug\Project1.exe.WebView2\EBWebView

I used the following code:
:
TMSFNCWebBrowser1.CacheFolder:='W:\Windows_Temp\Cache';
TMSFNCWebBrowser1.CacheFolderName:='Sessao_1';
TMSFNCWebBrowser1.AutoClearCache:=False;
TMSFNCWebBrowser1.Initialize;
:


In my application I display a page that processes a report (which can take several minutes).

When the report is finished, the page is updated informing that the report was sent to the informed email and I want to display an alert to the user.

It would be like, for example, using WhatsApp web and displaying a "popup" alert when receiving a new message.

Hi,

Can you change your code to:

TMSFNCWebBrowser1.CacheFolder:='W:\Windows_Temp\Cache';
TMSFNCWebBrowser1.CacheFolderName:='Sessao_1';
TMSFNCWebBrowser1.AutoClearCache:=False;
TMSFNCWebBrowser1.Deinitialize;
TMSFNCWebBrowser1.Initialize;

Worked, thank you.

About notifications, this is a browser specific feature. The embedded browser does not support the same kind of notifications through Windows as you get when running Facebook or Whatsapp. To notify the user the report is ready, you can install a JavaScript object bridge, then handle the notification in the client application that hosts the browser. I have attached a sample that demonstrates this.

CommBridge.zip (54.3 KB)

Thank you.

In Windows, the ".Deinitialize" solved this issue.

In macOS, ".Deinitialize" prevents TTMSFNCWebBrowser from displaying the page (it's like the property Visible is False).

The whole caching is only applied on Windows, there is no change needed for macOS. You can conditional define the code.

I need to create two TTMSFNCWebBrowser and each one must use a different cache folder.

How can I implement this on macOS?

Do you intend to implement CacheFolder and CacheFolderName on macOS as you did on Windows?

We'll have to investigate how the caching works in WKWebView (the native webbrowser used in macOS). As far as I can see, macOS automatically applies caching and it doesn't share the cache with another instance.