Posts: 52
Threads: 18
Joined: May 2019
Reputation:
0
Location: usa
Should I set each ISAPI IW apps's cache folder to a unique location. I have 4 IW apps all using the same location "C:\IWCACHE" and have noticed that there are a number of cache folders that are many days old. I am not sure if it because the App pool is timing out thus killing the IW app or a conflict with multiple apps writing to the same cache folder location.
My understanding is that the cache folders are deleted after several minutes past session timeout.
Posts: 83
Threads: 23
Joined: Feb 2022
Reputation:
1
Location: Melbourne
+1
I think this should be Ok, as it would generate unique names for sub-folders there per session anyway.
And I also see old folders left undeleted. Although I could swear those were being cleaned up at some point in the past. And I thought that was default IIS process, but I'm not sure. It would certainly be much better if something was automatically cleaning up those temp folders.
Posts: 147
Threads: 34
Joined: Jun 2018
Reputation:
3
Location: USA
I would separate them so that there is no conflict in the clean up process between applications.
Posts: 52
Threads: 18
Joined: May 2019
Reputation:
0
Location: usa
OK, I just created a simple IW .exe app with just a button. Set the timeout to 1 minute.
When I run the app I see the cache folder created with a user sub-folder and a session folder under the user folder.
I exit the browser and a few minutes later the session folder under the user folder is deleted.
I do not see where the cache's user folder is deleted or the cache folder under the main cache folder.
c:\iwcache
01dxjc923o
User
tNv9iUFipEomEgbdOBH3TZ1T~3C // only this folder is deleted when I close the browser
When does the top top level folders under C:\IWCACHE gets deleted?
Is there a way to force delete all folders under the C:\IWCACHE folder that are older then say 1 week?
Posts: 147
Threads: 34
Joined: Jun 2018
Reputation:
3
Location: USA
It just depends on how you want to do it. Having them all in the same cache folder is fine, but it just will not get cleaned up if the service is stopped.
So we separate them and then use the following code in the startup of the servercontroller just to make sure everything is cleaned up.
if SystemParams.ServerControllerParams.CacheDir <> '' then
begin
// Clear the cache directory to make sure that the temp folder is empty on startup,
// Check to make sure that it is not using the windows temp directory
if POS('windows',lowercase(SystemParams.ServerControllerParams.CacheDir)) = 0 then
begin
If SysUtils.DirectoryExists(trim(SystemParams.ServerControllerParams.CacheDir)) then
System.IOUtils.TDirectory.Delete(trim(SystemParams.ServerControllerParams.CacheDir),true);
end;
// Now recreate it
if Sysutils.ForceDirectories(SystemParams.ServerControllerParams.CacheDir) then
CacheDir := SystemParams.ServerControllerParams.CacheDir;
// Now recreate the Downloads directory (used for streaming non IW cache files)
if Sysutils.ForceDirectories(SystemParams.ServerControllerParams.CacheDir + '\Downloads') then
gDownloadDir := SystemParams.ServerControllerParams.CacheDir + '\Downloads\';
end;
Posts: 147
Threads: 34
Joined: Jun 2018
Reputation:
3
Location: USA
IW does clean up itself when the session is closed, etc.
In our case though we run under IIS and recycle the app pools in the middle of the night. If there are open sessions at that time the recycle would stop IW so it can not respond on anything that is currently open. That is why we do our own initialization of the cache folder on startup just to make sure everything is clean.
Posts: 39
Threads: 13
Joined: Nov 2019
Reputation:
0
Location: Dominican Republic
Hi!
I wrote myself an application that delete all the folders in the cache folder early in the morning.
Because I always found many old folders that IW didn't delete.
I recommend to you do the same.
Posts: 2,299
Threads: 202
Joined: Mar 2018
Reputation:
87
Location: Auckland, New Zealand
12-30-2023, 09:04 PM
(This post was last modified: 12-30-2023, 09:08 PM by Alexandre Machado.)
1- There is no problem using the same root folder as the application cache. IW will create a subfolder which is unique per application. There won't be any conflicts.
2- IW deletes all cache files and folder during shutdown. This has been extensively tested in multiple scenarios. However the deletion of files relies on the normal application shutdown. If the process is terminated externally the cleanup code is bypassed and the files won't be deleted.
Another scenario where cache files deletion may fail is due to AntiVirus software interference. Many cache files contain patterns that look especially interesting to AV software, like JavaScript code. When IntraWeb terminates, it will go through all the existing files trying to delete them. If deletion fails when trying to delete some specific file, it will pause for a few milliseconds and try again. However, if the file is still locked (in our tests, AV software, especially Windows Defender, frequently lock cache files), the process will skip this file and it won't be deleted. We prefer to skip the deletion of some file than to considerably delay the normal termination of the application. Remember that depending on the load, there may be several thousands cache files and waiting for each one even for a couple of seconds can make the termination process take a very long time.
Item (2) above is the reason we recommend to add the IntraWeb cache folder to the antivirus ignore list (most professional AV software has some configuration where you can exclude folders or files from being constant monitored). In general it not only fixes the problem of files not being deleted, but also increases the overall performance of the application.