Map caching based on feature boundaries
The ArcGIS Server map caching tools allow you to spatially constrain tile creation to the boundaries of a feature class. To do this, use the Update specific areas using a feature class option at the bottom of the Manage Map Server Cache Tiles tool.
Caching by feature class boundary allows you to create tiles only in the places where you need them, avoiding empty or uninteresting areas. For example, if you are caching a country, you might supply a feature class of major urban areas. By doing so, you are requesting that the server only precreate tiles that cover those urban areas. The rest of the areas can be cached on demand when requested by clients. This can save you time and disk space that would be consumed by creating unneeded tiles in rural areas.
The image below shows a theoretical grid of tiles that would be created if the feature class contained just the state of California. Using Update specific areas using a feature class avoids the creation of unneeded tiles in the ocean and in neighboring states. These unneeded tiles would have been included if the default rectangular extent were used.
Tracking the status of your cache
Caching by feature class not only saves you space but also helps you track the status of your cache. You can use the Manage Map Server Cache Tiles tool to mark which features have had tiles created over their areas. If you choose to use the status tracking, a Cached field is added to the feature class against which you are caching. When tiles have been created for the extent of a feature, that feature's Cached field is marked Yes.
If you run the tool to Update specific areas using a feature class again on the same feature class, the tool only creates tiles for records whose Cached field has not been marked Yes. This can be helpful if your previous caching job was interrupted and is usually faster than choosing the Recreate Empty Tiles option (which checks every tile in the cache). If you do not want the tool to start where it left off, you must either remove the Cached field, change its values to something other than Yes, or check the box to ignore status tracking.
Enabling status tracking allows you to recover from failed caching jobs much faster than using the Recreate Empty Tiles option.
Best practices
The following tips will help you efficiently create caches based on a feature class:
Only cache by feature class at large scales
At small scales, you create relatively few tiles, so it doesn't make much difference whether you cache by feature class or not. Creating all tiles at small and medium scales ensures that as users open your map and begin zooming in, they don't miss any tiles or have to create any tiles on demand.
To minimize duplicate labeling, the caching tools draw an image of a large area, or supertile, before cutting the image into tiles of the size you requested. When antialiasing is enabled, the supertile is 2048 x 2048 pixels; otherwise, it's 4096 x 4096. When your feature intersects the boundary of a supertile, that entire supertile must be created. This means it takes some zooming in before caching by feature class begins to have a real effect in saving time and disk space. If your features are numerous and all over the map, you may not get much benefit from caching by feature class because most of your features will intersect a supertile.
Generalize feature boundaries
Too many vertices in the feature class can slow down the caching tools, but fortunately you don't need to have a lot of vertices. The fact that the caching tools are drawing square areas tends to blunt whatever detailed features were in the feature class. Your feature class doesn't need to include every island, wharf, and inlet.
You can use the Simplify Polygon tool to systematically remove vertices from the feature class without changing the general shape. If your feature class is derived from a model, you may put Simplify Polygon as the final step in the model. Some tools, such as Buffer, can add an excessive number of vertices to your feature class.
The images below show how very similar sets of tiles get created whether you use a detailed or a generalized feature class. The second feature class has had most of the vertices removed using the Simplify Polygon tool. The gray squares represent a 4096 x 4096 supertile at about 1:4500.
Avoid small features
To get the most efficient CPU utilization, avoid using very small features to define your caching job. At any given time, each service instance (ArcSOC.exe process) is assigned to work on creating an area of tiles 128 tiles wide by 128 tiles high. No other ArcSOC.exe process can create tiles in that area. If your feature is smaller than this, it's possible you will only have one ArcSOC.exe process working on the caching. If a boundary of one of the 128 x 128 regions happens to cross your feature, you may get two or more ArcSOC.exe processes working on the cache; however, the boundary is based on the tiling origin and it's not always feasible to calculate where it will fall.
The best practice is to create large features to define your caching job. Large features encompass many of these 128 x 128-tile areas, so that your ArcSOC.exe processes will be busy most of the time.
Dissolve many features into few
One way to get large features from small features is to use the Dissolve tool. This tool takes multiple individual features and converts them into one multipart feature. Another useful tool with a similar effect is Aggregate Polygons, which removes small polygons or combines small polygons into one larger polygon shape. Both tools will help you get more efficient use of your service instances when caching.
Use regions to track status
After you dissolve your feature class as described above, consider cutting it into a few large regions so that you can still track the status. Finding the best size for the regions can be a challenge. You want the regions to be large enough that you get the most efficient use of your ArcSOC.exe processes, as described above; however, you want the regions to be small enough that you don't lose too much work if tile creation fails.
One effective way to create regions for caching is to make a grid with the Create Fishnet tool and clip it to your feature class boundary. You can keep a copy of the clipped grid open in ArcMap and follow along as the caching tools report "Processing feature with OID = 8", "Processing feature with OID = 9", and so on.
You might want to do some manual postprocessing on your gridded feature class to merge some of the smallest features with their larger neighbors. In the graphic above, notice how small islands were dissolved into their neighboring regions to avoid the inclusion of very small features.