TileCache is a BSD licensed tile caching mechanism. The goal is to make it
easy to set up a WMS or TMS frontend to any backend data services you might be
interested in, using a pluggable caching and rendering mechanism.
TileCache was developed by MetaCarta Labs and released to the public under a
The TileCache was designed as a companion to OpenLayers, the BSD licensed web
mapping interface. If you are using TileCache with OpenLayers, please read the
section of this readme which describes how to do so. For additional help with
setting up TileCache for use with OpenLayers, please feel free to stop by
#openlayers, on irc.freenode.net, or to send email to
This implementation also depends on Python Paste, which can be downloaded
via the python-paste package:
Once you have done this, you can configure your fastcgi server to use
Configuring FastCGI is beyond the scope of this documentation.
TileCache is configured by a config file, defaulting to tilecache.cfg.
There are several parameters to control TileCache layers that are applicable
to all layers:
The bounding box of the Layer. The resolutions array defaults
to having resolutions which are equal to the bbox divided by
512 (two standard tiles).
Whether to send debug output to the error.log. Defaults to "yes",
can be set to "no"
Layer description, used in some metadata responses. Default
File extension of the layer. Used to request images from
WMS servers, as well as when writing cache files.
A string used to describe the layers. Typically passed directly
to the renderer. The WMSLayer sends this in the HTTP request,
and the MapServerLayer chooses which layer to render based on
this string. If no layer is provided, the layer name is used
to fill this property.
An integer, describing the number of 'zoom levels' or
scales to support. Overridden by resolutions, if passed.
The absolute file location of a mapfile. Required for
MapServer and Mapnik layers.
The maximum resolution. If this is set, a resolutions
array is automatically calculated up to a number of
levels controlled by the 'levels' option.
set to "yes" to turn on metaTiling. This will request larger
tiles, and split them up using the Python Imaging library.
Defaults to "no".
an integer number of pixels to request around the outside
of the rendered tile. This is good to combat edge effects
in various map renderers. Defaults to 10.
A comma separated pair of integers, which is used to
determine how many tiles should be rendered when using
metaTiling. Default is 5,5.
Comma separate list of resolutions you want the TileCache
instance to support.
Comma separated set of integers, describing the width/height
of the tiles. Defaults to 256,256
String describing the SRS value. Default is "EPSG:4326"
The type of layer. Options are: WMSLayer, MapnikLayer, MapServerLayer,
URL to use when requesting images from a remote WMS server. Required
The watermarkImage parameter is assigned on a per-layer basis.
This is a fully qualified path to an image you would like to apply to each
tile. We recommend you use a watermark image the same size as your tiles.
If using the default tile size, you should use a 256x256 image.
NOTE: Python Imaging Library DOES NOT support interlaced images.
The watermarkOpacity parameter is assigned on a per-layer basis.
This configures the opacity of the watermark over the tile, it is a floating
point number between 0 and 1. Usage is optional and will otherwise default.
Setting this to 'loose' will allow TileCache to generate tiles outside the
maximum bounding box. Useful for clients that don't know when to stop
asking for tiles.
Setting this to "google" will cause tiles to switch vertical order (that
is, following the Google style x/y pattern).
USING TILECACHE WITH OPENLAYERS
To run OpenLayers with TileCache the URL passed to the OpenLayers.Layer.WMS
constructor must point to the TileCache script, i.e. tilecache.cgi or
tilecache.py. As an example see the example-cgi.html file included in the
TileCache distribution, under /usr/share/doc/tilecache/examples/.
Note: example-cgi.html assumes TileCache is set up under CGI (see above). If
you set up TileCache under mod_python you'd need to slighly modify
example-cgi.html: the URL passed to the OpenLayers.Layer.WMS constructor must
point to the mod_python script as opposed to the CGI script. Similarly, you
would need to edit this URL if you were to use TileCache with the standalone
HTTP Server or FastCGI.
The most important thing to do is to ensure that the OpenLayers Layer
has the same resolutions and bounding box as your TileCache layer. You can define
the resolutions in OpenLayers via the 'resolutions' option or the 'maxResolution'
option on the layer. The maxExtent should be defined to match the bbox parameter
of the TileCache layer.
USING TILECACHE WITH MAPSERVER
MapServer has a map level metadata option, labelcache_map_edge_buffer, which
is set automatically by TileCache to the metaBuffer plus five when metaTiling
is on, if it is not set in the mapfile.
Maximum cache entries. This limits the
amount of memory that will be used to store
information about tiles to remove.
The --entries option to tilecache_clean.py is optional, and is used to regulate
how much memory it uses to do its bookkeeping. The default value of 1 million
will hopefully keep RAM utilization under about 100M on a 32-bit x86 Linux
machine. If tilecache_clean.py doesn't appear to be keeping your disk cache
down to an appropriate size, try upping this value.
tilecache_clean is designed to be run from a cronjob like so:
Occasionally, for some reason, when using meta tiles, your server may leave
behind lock files. If this happens, there will be files in your cache directory
with the extension '.lck'. If you are seeing tiles not render and taking
multiple minutes before returning a 500 error, you may be suffering under
a stuck lock.
Removing all files with extension '.lck' from the cache directory will
resolve this problem.