What is image service caching?

Image service caching improves the performance of image services in client applications. When you cache an image service, the server pregenerates tiles at different levels, which can be pushed out faster than processing the input from the mosaic dataset or the raster dataset each time a request is made from ArcGIS for Server. An important aspect of an image service cache is that it is not serving imagery that is processed on the fly—it is preprocessing the imagery to create the cached tiles and serving the cached tiles.

When you cache an image service you end up with a dual-purpose image service which is accessed depending on its purpose. One purpose is to provide the fastest access to the image as a tiled service. The other purpose is to provide access to the data, for queries, downloading, access to individual items, and to use in processing and analysis.

NoteNote:

All image cache is stored as 8-bit data.

Why should I cache image services?

The main benefit of caching an image service is to improve its performance. The cached image service can display an image very fast because ArcGIS Server does not have to generate the image dynamically. Specific benefits of a cached image service include:

How is the cache created?

Caching does not happen automatically. First you must share a mosaic dataset or raster dataset as an image service. Next, you'll set some cache properties. Then you can begin creating the cache.

When you cache an image service, it generates a collection of image tiles at multiple, predefined scale levels or pixel sizes, similar to map service caching. This allows users to zoom in and out quickly, but only at those matching scales. Also, the image service cache is created using a default RGB band combination and mosaic method.

Tiling scheme

The scales that you pick and the properties you set for the cache constitute the tiling scheme. The tiling scheme should be consistent with the other layers you may be integrating. For example, you can choose to use the well-known tiling scheme of ArcGIS Online, Google Maps, and Bing Maps so that you can easily overlay your caches with these online mapping services, or you can create your own tiling scheme to be consistent within your own web application. Each cache has a tiling scheme file that you can import when you create new caches so that all your caches use the same tile sizes and scales.

If your tiling scheme doesn't match the one used by the other layers in your application, then you may not see your cached layers. This is because web clients often cannot resample your data to display it at a different level (unlike ArcMap).

If creating your own unique tiling scheme, you may want to choose scales or pixel size intervals that match the overviews of your mosaic dataset or pyramids in a raster dataset. This helps improve the quality of the cache if it can be created from an overview or pyramid that is close to or the same as the cache interval that is being created; otherwise, a cached tile runs the risk of being created from other cached tiles, which may degrade the image quality. It may help to preview the source data in ArcMap at each scale to be sure the imagery looks good, then use those scales in the tiling scheme.

You can also control the base cell size of the cache by entering a value for the Maximum source cell size on the Advanced Settings page for caching. You may use this, for example, to start building the cache where the overviews or pyramids stopped.

Cache tiles

The cache tiles are processed and stored in JPEG or PNG format so that the server can distribute these images whenever there is a request.

The cache is stored in your server cache directory. When you installed ArcGIS for Server, a server cache directory was created for you in a local folder. If you add more GIS servers to your site, you need to share your server cache directory (using operating system options such as Windows file sharing) so it can be accessed by other machines in your site.

For all its performance benefits, caching comes with some overhead. You need time and server power to create the cache tiles and hardware to store them. You may also need to perform cache updates if, for example, your source data, such as a mosaic dataset, is being edited. If your application offers imagery for a vast area at a large scale, you may decide that the time and storage required to build and maintain the cache outweighs the performance benefit.

Learn the steps to create an image service cache

On demand cache

On-demand caching allows you to set up the tiling scheme and publish the image service, but only generate the cache when and where a user accesses the service. The first user to navigate to an uncached area must wait while the corresponding tiles are drawn by the server. The tiles are then added to the service's cache folder and remain on the server until updated or deleted by the server administrator. This means that subsequent visitors to the area will not have to wait for the tile to be created.

When used wisely, on-demand caching can save you time and disk space. Many image services contain some area that is barren or uninteresting to the audience, especially at large scales (zoomed in). Caching on demand relieves you of the burden of creating and storing these unneeded tiles but leaves the possibility that a user could still view the area if needed.

There are many recommendations for creating on-demand cache that apply to both map services and image services. To learn about them, see Map caching on demand.

CautionCaution:

For image services created using a mosaic dataset: When generating the cache on demand or only generating one level of cache, you need to be certain that the cache can be created; otherwise, the cache will be blank. If generating the cache on demand, verify that the imagery is visible for each cache level. If it is not, build the mosaic dataset overviews or alter the other settings that can impact the image visibility. When using the Manage Map Server Cache Tiles tool, do not build or rebuild random scales. Build all the scales or only build a small scale if the previous larger scale is built.

Should I cache my image services?

An image service cache represents a snapshot of your image service at one point in time, with one or three bands, and using a specific mosaic method. Because of this, caches work best with image services that do not change frequently, such as a collection of digital orthophoto quads or a hillshaded elevation image service.

If your data tends to change (for example, with frequent updates), you can use the caching tools to periodically update the cache. You can even schedule these updates to occur automatically.

If the source data of an image service needs to be live, with no acceptable time delay, then you might want to consider using an on-demand cache.

If the update cannot keep up with the changes in an acceptable amount of time or the image service has to be changed frequently with different image properties, then the image service is not appropriate for caching.

Dive-inDive-in:

ArcMap normally applies a stretch to any raster data when it's added to the display, so you may notice that the image service doesn't look the same in a web application as it does in ArcMap. In order to make them look the same, you can export the stretch applied in ArcMap and add it to the image service before publishing and caching.

To learn about exporting the stretch in ArcMap, see Saving a raster function template from the layer's symbology.

To learn about applying the raster function template (*.rft.xml) to the image service, see the section titled Parameters to control on-the-fly processing.

How do I update my image service cache?

The image service cache is managed similar to the way the map service cache is managed.

If the items of the mosaic dataset are updated for image services created from mosaic datasets, then run the Compute Dirty Area tool to produce a feature class identifying the modified areas. This feature class can be used to rebuild the affected cache tiles.

Learn about the tools to update caches

Accessing a cached vs noncached image service

When you display an image service in ArcMap that has been cached, it will have limited image service capabilities. For example, you will not be able to change the mosaic method or transmission compression method. But you will still be able to do things like change the symbology and enhancement, perform an identify on the pixels, query the data, and download the source data.

If you need to work with the image service dynamically and use functionality such as the mosaic method, then you can change the layer's mode. To change the mode, right-click the image service layer and uncheck Enable Cache View Mode. To use the image service as a cached service, just check this option back on.

To access a cached image service in a web application (such as using Flex), use the ArcGISTiledMapServiceLayer class; to access it as a dynamic image service, use the ArcGISImageServiceLayer class. You can also access a cached image service using the Open Geospatial Consortium, Inc. (OGC), Web Map Tile Service (WMTS) protocol.

The image service REST endpoint supports both ExportImage, which provides the dynamic image service, and GetTile, which provides access to the cached image service.

Learn more about accessing cached image services

Related Topics

9/1/2015