Recently I’ve noticed that ArcGIS does not store its tile-caching data in the standard service configuration file [Program Files\ArcGIS\server\user\cfg\myService.MapServer.cfg]. Instead these get saved to the cache directory [arcgisserver\arcgiscache\myService\Layers\conf.xml].
Why? The ArcGIS Server Manager gives us a clue if we try to edit the caching properties of a stopped service: “Caching properties and tools are available only when the service is started.”
This is interesting. The AGS Server Object Manager can edit the standard “myService.MapServer.cfg” files directly via the IServerObjectAdmin interface. An AGS Server Object Container, or more precisely an IMapCooker2 instance, is needed to write the “conf.xml” file. Here’s the general code:
IMapCooker2 cooker = pServerContext.CreateObject("esriCarto.MapCooker") as IMapCooker2;
cooker.Connect(physicalCacheDirectory, myMapName, myMap);
ITileCacheInfo pCacheInfo = cooker.TileCacheInfo;
ITileImageInfo2 pTileImageInfo = (ITileImageInfo2)cooker.TileImageInfo;
// do things here
cooker.WriteTilingScheme(pCacheInfo, pTileImageInfo, physicalCacheDirectory, LayerName);
Interesting, but here’s the catch: I can’t find a way to access an AGS MapService’s IMapCooker2 instance at runtime. My last post showed how to modify an AGS’s service layers at load. However, this relied on runtime access to the IMap. In essence, you can’t [AFAIK] change an AGS Mapservice’s SOC’s caching characteristics at runtime; you must restart the service to reload this data from the “conf.xml” file.