Creating a Tile Cache Using Apache

Caching of map tiles can be performed using the Apache HTTP Server's built-in caching mechanism. To set up a tile cache for pre-rendered or on-the-fly tiles:

  1. Download and install an instance of the Apache HTTP Server that will act as the front end to your Spectrumâ„¢ Technology Platform installation.
    Note: The Apache web server must be installed on a machine that has network access to the one that hosts Spectrumâ„¢ Technology Platform.

    The front-end Apache server will act as a sort of filter, intercepting NamedTile requests so that the requested map tiles can be cached to disk.

  2. Modify the Apache server's configuration file: apache_install_dir/conf/httpd.conf.
    1. Open httpd.conf in a text editor.
    2. In httpd.conf, find this line...

      Listen 80

      ...and immediately below it, add this line...

      Listen 90

    3. At the end of the file, add this line...

      Include conf/tilecaching.conf

    4. Save the changes you have made to httpd.conf, and close the file.
  3. In the apache_install_dir/conf directory, create a new file named tilecaching.conf.
    1. Open tilecaching.conf in a text editor, and add the following lines:
      Note: Placeholder values are shown in bold italics. Replace them with the actual values for your system.
      LoadModule proxy_module modules/mod_proxy.so
      LoadModule proxy_http_module modules/mod_proxy_http.so
      LoadModule headers_module modules/mod_headers.so
      
      <Directory"c:/maptilecache_dirname">
          AllowOverride None
          Order allow,deny
          Allow from all
      </Directory>
      
      NameVirtualHost *:90
      NameVirtualHost *:80
      
      ProxyRequests off
      ProxyPreserveHost On
      
      <Proxy *>
          Order allow,deny
          Allow from all
      </Proxy>
      
      <VirtualHost *:80>
          ServerName spatialserver
      
          <Location /rest/MapTilingService/NamedTiles/>
              RequestHeader unset Authorization
          </Location>
      
          ProxyPass /rest/MapTilingService/NamedTiles/ http://spatialserver:90/rest/MapTilingService/NamedTiles/
          ProxyPassReverse /rest/MapTilingService/NamedTiles/ http://spatialserver:90/rest/MapTilingService/NamedTiles/
      
          ProxyPass / http://spatialserver:8080/
          ProxyPassReverse / http://spatialserver:8080/
      </VirtualHost>
      
      <VirtualHost *:90>
          ServerName spatialserver
      
          ProxyPass / http://spatialserver:8080/
          ProxyPassReverse / http://spatialserver:8080/
      
          <Location /rest/MapTilingService/NamedTiles/>
              Header merge cache-control "public"
              RequestHeader set Authorization "Basic YWRtaW46YWRtaW4="
          </Location>
      
          LoadModule cache_module modules/mod_cache.so
          LoadModule disk_cache_module modules/mod_disk_cache.so
          CacheRoot c:/maptilecache_dirname
          CacheEnable disk /rest/MapTilingService/NamedTiles/
          CacheIgnoreHeaders None
      </VirtualHost>
    2. Save the changes you have made to tilecaching.conf, and close the file.
  4. Create the directory that will hold the cached map tiles. Give the directory a name that will make its purpose clear, such as maptilecache.

    Be sure to specify the name correctly in the tilecaching.conf configuration file.

  5. Restart the Apache web server.