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:
-
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.
-
Modify the Apache server's configuration file:
apache_install_dir/conf/httpd.conf.
- Open httpd.conf in a text editor.
-
In httpd.conf, find this line...
Listen 80
...and immediately below it, add this line...
Listen 90
-
At the end of the file, add this line...
Include conf/tilecaching.conf
- Save the changes you have made to httpd.conf, and close the file.
-
In the apache_install_dir/conf
directory, create a new file named tilecaching.conf.
-
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>
- Save the changes you have made to tilecaching.conf, and close the file.
-
Open tilecaching.conf in a text editor, and add
the following lines:
-
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.
- Restart the Apache web server.