In order to improve performance, IntraWeb keeps files that can be cached (files from the Files directory etc) in a directory named Cache. By default this directory is created the first time the application saves a cached file in the system temp folder.  You can change the default name and location of the cache directory via ServerController.CacheDir.

There are several rules that apply to the Cache directory:

  • The application should not save files for later use in the Cache directory, since all files in that directory are deleted automatically. Files older than the value (in minutes) in ServerController.CacheExpiry are deleted. 
  • when deploying an IntraWeb application, always make sure that it has full access (read, write, modify etc) to the Cache directory, otherwise the application will run with unpredictable results (access violations, internal errors etc). 

Global Cache Directory

The global cache directory is accessible for all users/sessions.

Files in that directory can be reached from the Web browser like this:

http://127.0.0.1:8080/cache/XYZ1234.tmp   - where XYZ1234.tmp is a cache file

Empty files can be created as follows:

uses IWGlobal;
...
 LFilePathName := GServerController.NewCacheFile('XYZ');

That will create a file named XYZ1234.tmp - XYZ is the given prefix, 1234 is a random number, and .tmp cannot be influenced.

NewCacheFile()returns the full physical path to the newly created file.

User/Session Cache Directory

the User Cache Directory is private per user/session. It is protected by the non-guessable session id.

To find the URL to a file in the User Cache Directory, use this approach:

uses IWGlobal;
...
 LFileURL := GServerController.UserCacheURL + 'mytempfile.tmp

The physical location can be determined this way:

LFileURL := GServerController.UserCacheDir + 'mytempfile.tmp

A new file in the User Cache is created by:

LFilePathName := GServerController.NewCacheFile('XYZ', true);