Tips and best practices for map caches
The tips below can help you achieve the best appearance and performance for your map caches. The tips are arranged in the following categories:
Preparing the map document
- Do not include spaces or nonalphanumeric characters in data frame names. When the data frame names are included in URLs, some Web servers may have difficulty interpreting spaces or special characters.
- If possible, choose the scales you want to cache before you start designing the map. Work at those scales as you create the map in ArcMap. For quick reference, you can manually load those scales into the drop-down list of scales in ArcMap.
- Before caching your map, do a visual check of the source map document at each scale that you plan to cache. Make sure that the appropriate layers appear with effective symbology and labeling at each scale. If you need to change the symbology of a layer based on scale, you can copy the layer and paste it back into the ArcMap table of contents. Set a scale range on each copy of the layer and symbolize appropriately for that scale range.
The images below show an ArcMap document that has been symbolized for viewing at two scales. The author of this map copied and pasted the Interstates and Cities layers back into the data frame, then symbolized a zoomed in and zoomed out version for each layer.
In the zoomed out map, the author set a definition query to limit the visible cities to those with a population of more than 50,000. Also, the author symbolized the Interstates layer with a thin line.
In the zoomed in map, the author removed the definition query so that all cities are visible. However, the author added label rules that symbolize larger cities with a larger font. The author also changed the Interstate symbolization to use a thicker cartographic line symbol.
The author set scale ranges on both the zoomed in and zoomed out layers to ensure that only one of the layers is visible at any given scale. The Rivers and Lakes, County Boundaries, Parks, and State Background layers use the same symbol whether zoomed in or out, so the author did not create copies of these layers.
If you're creating a map that you intend to cache at many scale levels, you will need to repeat this process, potentially creating many copies of layers in your map document. Use group layers to keep them organized.
- Use the Maplex labeling engine in your map document. This will give you the best possible label placement while caching.
- Set X Offset and Y Offset values on text symbols to 0. Using text symbol offsets may result in periodic inadvertent label truncation. Use the label engine's offset ability instead.
- Explicitly define a data frame background color not used elsewhere in your map (RGB 254,255,255 is a good choice). Otherwise, any symbols and text that happen to be the same as the background color may be rendered improperly when the background is interpreted as transparent in certain browsers.
You can explicitly set the background color in ArcMap. The background will render as transparent in environments that support PNG 24 transparency.
- Before starting a large caching job, make a test cache of a small area at all scale levels. You can do this by making a small feature class that covers your test area. Then, when you create the cache, choose the option to create tiles based on the boundary of that feature class. When you've created the cache for this small area, examine the tiles to make sure they look and perform the way you expect. One way to do this is to use the Services Directory to preview the service.
Creating the cache
- Use fused caches or combinations of fused caches whenever possible. If you use multilayer caches, ArcMap is the recommended client application.
- Make sure you've created enough scales. Web application users can only see the map at the scales you cache.
ArcMap users see resampled cache tiles when they are in between scales. Caching too few scales causes more resampling and possible distortion of features.
- Choose your closest scale level carefully. Your closest (largest) scale is the one that will take the longest time to cache and the most storage space. It should be zoomed in just as far as you need without getting any closer.
- Try to use the same tiling scheme for all caches created in your organization. If you'll be bringing cached services into your Web applications from another organization or department, you may want to match their tiling scheme or agree on one that you can both share.
- When creating caches that will overlay each other in a Web application, use the same tiling scheme if possible. It's not required that you create all the caches at all the same scale levels. However, you should match as many scales as possible.
In the image below, three caches with different scale ranges share the same scales where possible. Shared scales are circled in red:
- When creating cache tiles, use the Update specific areas using a feature class option to avoid creating tiles for areas that you don't need. It may be useful to create a new feature class that specifically outlines the areas that you want to precreate. You can use this feature class whenever you create or update your cache.
- Avoid using on-demand caching to build your entire cache. A good practice is to precreate tiles for areas that you anticipate will be frequently visited and use on-demand caching only for areas that will be visited rarely.
- Examine the geoprocessing tool messages after running Manage Map Server Cache Tiles. If any ArcSOC.exe processes crashed during tile creation, the scales and extents of the missed areas will be written in the geoprocessing tool messages. You can then re-run the cache for these particular extents to fill in the missing tiles.
Although you should try to match tiling schemes when building your caches, you do not need to match the image format. After importing a tiling scheme file, you can change the image format before you create the cache. Use these guidelines to choose the appropriate image type for each individual cache:
- Use JPEG format for raster-based basemaps with a lot of color variation, such as imagery.
- Use JPEG or PNG formats for vector-based basemaps such as street maps. Maps with just a few simple colors should use PNG.
- Use PNG for overlay services, such as boundaries, road networks, or any features that require background transparency.
- Avoid using PNG 8 if your map has more than 256 colors.
- Avoid using PNG 24 if your tiles will be viewed in Internet Explorer 6.
Maintaining the cache
- If your source data tends to change, you can use a Python script to automatically run the Manage Map Server Cache Tiles geoprocessing tool on a regular basis. This tool can update all or selected areas of your cache. See Automating cache creation and updates with geoprocessing for an example.
- If you have very large caches and you need to run the GIS Server Post Install, be aware that it may take the postinstallation a long time to apply the necessary permissions to every file in the cache. See ESRI Knowledge Base Article 32766 for a way to work around this. Applying a service pack is an example of a situation where you would need to run the GIS Server Post Install.
- After the cache is created, if you don't want to continue storing all the source data on your server, you can remove some of the layers from the source map document. Leave at least one layer in the map document (a suggestion is a simple feature class with one feature covering the map extent), and leave the map document in the coordinate system used to create the cache. After you restart the service, you can safely remove the source data from the server for any layers you removed. As long as the service name and the cache name stay the same, users will continue to see the cache when they view the service.
Keep in mind that if you use this technique, users will not get any meaningful results when they query the service. If you want to maintain some queryable layers, you should leave them in the map document and leave the source data for those layers on the server.