Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Just a forewarning, I will try to be as extensive with my question as possible. Due to a number of reasons why this might not be working, I have posted all sorts of portions of my debugging below.

Web map located here

Tile cache is being setup as a test run for the "hii_5" layer in OpenLayers. MapServer is the backend.

I am trying to get TileCache to cache images of my MapServer WMS. However, no images are produced. The TileCache is "trying" to load the tiles (as you can see on the live page), however, no images are returned.

When I follow the path of one of the image tiles, I see this error:

An error occurred: File contains parsing errors: C:\ms4w\Apache\cgi-bin\tilecache.cfg
    [line 82]: '  type=WMS\n'
    [line 83]: '  url=\n'
    [line 84]: '  mapfile=C:/ms4w/Apache/htdocs/moot2_dev/\n'
    [line 85]: '  extension=png\n'
    [line 86]: '  layers=HII_railroads\n'
  File "C:\ms4w\Apache\cgi-bin\TileCache\", line 85, in _load
  File "C:\Python27\lib\", line 297, in read
    self._read(fp, filename)
  File "C:\Python27\lib\", line 538, in _read
    raise e

Here are the relevant mapfile, tilecache.cfg, and openlayers source:

Not sure how much help I will get here, but the questions out there for anyone to take a stab at it!

MAP                                                     #-> BEGIN MAP
    OUTPUTFORMAT                                        #-> BEGIN OUTPUT FORMATTING DEFINITION
        NAME "png"                                      # Name of format
        DRIVER AGG/PNG                                  # Image driver
        MIMETYPE "image/png"                            # Type of image
        IMAGEMODE RGBA                                  # Image mode
        EXTENSION "png"                                 # Image filetype
        TRANSPARENT ON                                  # Transparency
    END                                                 #-> END OUTPUT FORMATTING DEFINITION

    WEB                                                 #-> BEGIN WEB DEFINITION

            "wms_title"           "HII_railroads"
            "wms_onlineresource"  ""
            "wms_srs"             "EPSG:3857"
            "ows_enable_request"  "*"

        TEMPLATE "template.html"
        IMAGEPATH "/ms4w/tmp/ms_tmp/"
        IMAGEURL "/ms_tmp/"
    END                                                 #-> END WEB DEFINITION

LAYER                                                   #-> BEGIN LAYER DEFINITION: Railroads <-#

        "wms_title" "HII_railroads"

    NAME    HII_railroads                               # Layer identifier
    DATA    "data/wgs84/railroads_360.tif"              # Name of the data (in this case, string identifying a raster)
    STATUS  ON     




hii_5 = new OpenLayers.Layer.WMS("Railroads","../../cgi-bin/tilecache.cgi?",{
share|improve this question
up vote 2 down vote accepted

This issue is coming directly from ConfigParser, in Python. Glancing at your config, it looks like you have spaces at the beginning of your newlines, indenting your configuration options. If that's the case -- don't do that. I'm pretty sure that ConfigParser is refusing to parse that file.

share|improve this answer
This helped, however I have a new problem. See updated question. Thanks a lot Christopher. – Michael Markieta Jan 31 '12 at 1:18

Your tilecache.cfg file seems to be missing the mandatory [cache] section. Try adding:


There are a few other options other than saving your cache to disk:

# [cache] section examples: (mandatory!)
# Disk:
# [cache] 
# type=Disk   (works out of the box)
# base=<full path to cache directory>
# Memcached:
# [cache]
# type=Memcached  (you'll need and memcached running!)
# servers=
# Amazon S3:
# [cache]
# type=AWSS3
# access_key=your_access_key
# secret_access_key=your_secret_access_key
share|improve this answer
Sorry, thought this might have been the answer I was looking for but it seems I have already set that part up :). Getting closer though it seems, see updated question. – Michael Markieta Jan 31 '12 at 1:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.