When using the BitmapViewer web control, we need to store the image data between sessions. The standard approach in ASP.NET is using a System.Web.UI.Control.ViewState (i.e. save the necessary data in the HTML page). However since the images are typically too large, this approach is not good because of huge overheads.
That's why Graphics Mill for .NET implements another approach - saving the temporary images in the special folder at server disk, called an image cache.
When ASP.NET 2.0 is used, Graphics Mill for .NET automatically creates image cache in the App_Data. But if necessary, you can override the cache location using web.config in the same way as described here. For example, you may find ability to specify image cache folder manually useful to share image cache across servers in a web farm.
Image caching is used for two tasks, and that's why the web controls of Graphics Mill for .NET have two caches:
To set the image cache up, you should use Aurigma.GraphicsMill.WebControls section of the web.config file of your application. To do it, declare this section in the configSection tag. After that you should insert the Aurigma.GraphicsMill.WebControls section and put necessary keys as described further. As a result, the web.config should be looking like that:
<?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="Aurigma.GraphicsMill.WebControls" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> </configSections> <system.web> <!-- ... other settings ... --> </system.web> <Aurigma.GraphicsMill.WebControls> <!-- ... Settings of web controls including cache options ... --> </Aurigma.GraphicsMill.WebControls> </configuration>
To specify the path to the public and private cache use the following keys:
These URLs should be specified relatively the site root and begin from the forward slash character (/).
Also, if you do not want to have the private cache inside the site root, and prefer to specify physical path, use the AbsolutePrivateCachePath key. However you cannot specify absolute path for the public cache, because it is sent to browser, and therefore should point to some folder inside your web site.
If you specified relative path to the private cache, you should not use absolute path, and vice versa.
Here is an example of these keys usage:
<?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="Aurigma.GraphicsMill.WebControls" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> </configSections> <system.web> <!-- ... --> </system.web> <Aurigma.GraphicsMill.WebControls> <add key="RelativePrivateCachePath" value="/WebQuickStartVB/PublicTemp/" /> <add key="RelativePublicCachePath" value="/WebQuickStartVB/PrivateTemp/" /> </Aurigma.GraphicsMill.WebControls> </configuration>
Do not forget to set up proper permissions for these folders. Both of them should have modify permission for the user the ASP.NET process is running under. On Windows NT/2000/XP this is typically an internet user (IUSR_<machinename>) and ASPNET account. On Windows 2003 grant modify permission to NETWORK SERVICE group.
Also, to increase the security, deny the script execution in these folders using IIS Management Console. See the Quick Start in Web Forms article for more details.
When cached files are no longer needed, Graphics Mill for .NET removes them. The file is removed from the cache when:
Since public and private caches have absolutely different intent, you should use different cleanup policies for them. Use the following considerations when choosing these settings:
Also, since there are quite large number of such files, especially if user zooms and scrolls the image intensively, it is recommended to specify big value here.
As for file count, there are much less files stored in the private cache. That's why you can specify smaller value than for the public cache.
The full example of cache settings is below:
<?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="Aurigma.GraphicsMill.WebControls" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> </configSections> <system.web> <!-- ... --> </system.web> <Aurigma.GraphicsMill.WebControls> <add key="RelativePrivateCachePath" value="/WebQuickStartVB/PublicTemp/" /> <add key="RelativePublicCachePath" value="/WebQuickStartVB/PrivateTemp/" /> <add key="PrivateCacheMaxLifeTime" value="1200" /> <add key="PrivateCacheMaxFileCount" value="200" /> <add key="PublicCacheMaxLifeTime" value="300" /> <add key="PublicCacheMaxFileCount" value="500" /> </Aurigma.GraphicsMill.WebControls> </configuration>