When using the BitmapViewer AJAX 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.
Image caching is used for two tasks, and that's why the AJAX Controls of Graphics Mill for .NET have two caches:
Graphics Mill for .NET AJAX Controls automatically create image cache in the App_Data/GraphicsMillAjaxCache and allow to work with it without any additional settings. The image cache management mechanism for the BitmapViewer is performed via the HTTP module. If necessary, you can override the cache location using web.config in the same way as described below.
To set the image cache up, you should use Aurigma.GraphicsMill.AjaxControls 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.AjaxControls 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.AjaxControls" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> </configSections> <system.web> <!-- ... other settings ... --> </system.web> <Aurigma.GraphicsMill.AjaxControls> <!-- ... Settings of web controls including cache options ... --> </Aurigma.GraphicsMill.AjaxControls> </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.AjaxControls" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> </configSections> <system.web> <!-- ... --> </system.web> <Aurigma.GraphicsMill.AjaxControls> <add key="RelativePrivateCachePath" value="/AjaxControls/GraphicsMill/PrivateCache/" /> <add key="RelativePublicCachePath" value="/AjaxControls/GraphicsMill/PublicCache/" /> </Aurigma.GraphicsMill.AjaxControls> </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.
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.AjaxControls" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> </configSections> <system.web> <!-- ... --> </system.web> <Aurigma.GraphicsMill.AjaxControls> <add key="RelativePrivateCachePath" value="/AjaxControls/GraphicsMill/PrivateCache/" /> <add key="RelativePublicCachePath" value="/AjaxControls/GraphicsMill/PublicCache/" /> <add key="PrivateCacheMaxLifeTime" value="1200" /> <add key="PrivateCacheMaxFileCount" value="200" /> <add key="PublicCacheMaxLifeTime" value="300" /> <add key="PublicCacheMaxFileCount" value="500" /> </Aurigma.GraphicsMill.AjaxControls> </configuration>