Tile cache
GC2 (Geo Compute Cloud) serves every layer as tiles as well as through WMS. Tiles are drawn once and kept in a cache, so a map of many layers stays fast however heavy the data behind it is. This page covers the four parts of the tile side:
- Fetching tiles through the tile proxy, as WMTS, TMS or XYZ.
- Schema tilesets: one tileset drawn from every layer of a schema, and its settings.
- Deleting cached tiles when data or styling has changed.
- Seeding: drawing tiles ahead of time with jobs.
Tilesets
A tileset is a named set of tiles. There are two kinds:
| Tileset | Name | Holds |
|---|---|---|
| Layer | schema.table | Image tiles of one layer. schema.table.mvt and schema.table.json are its vector variants. |
| Schema | schema | Image tiles of every layer in the schema, drawn together. schema.mvt is the vector variant. |
Every tileset has a grid called g20. That is the grid's name; GoogleMapsCompatible is the title of the same grid, as shown in capabilities documents.
Fetch tiles
Tiles are fetched through a proxy that authorizes each request before it reaches the cache:
https://api.gc2.io/api/v4/mapcache/database/{database}/{path}
It is one of the public routes: it takes an Authorization: Bearer token, HTTP Basic or no credentials, and each tile request is authorized against the tileset's layer. A layer that is open to everyone can be fetched without credentials; a tileset the caller may not read is 403.
The {path} is the service path, and the grid is written differently in each service:
| Service | Path | Grid |
|---|---|---|
| TMS | tms/1.0.0/{tileset}@{grid}/{z}/{x}/{y}.{ext} | @ suffix on the tileset name |
| XYZ | gmaps/{tileset}@{grid}/{z}/{x}/{y}.{ext} | @ suffix on the tileset name |
| WMTS | wmts/1.0.0/{tileset}/default/{grid}/{z}/{y}/{x}.{ext} | Its own path segment |
| WMTS capabilities | wmts/1.0.0/WMTSCapabilities.xml |
GET https://api.gc2.io/api/v4/mapcache/database/mydb/gmaps/rockhall.inductees@g20/10/512/340.png HTTP/1.1
GET https://api.gc2.io/api/v4/mapcache/database/mydb/wmts/1.0.0/rockhall.inductees/default/g20/10/340/512.png HTTP/1.1
Authorization: Bearer abc123
A tile request whose tileset name cannot be resolved is answered with 403, not 404. Writing the grid with @ in a WMTS path, or as a path segment in a TMS or XYZ path, gives exactly that, so a 403 on a tile is as often a mistake in the URL as a matter of access.
Schema tilesets
The schema tileset is drawn from all the layers of a schema at once, so a client loads one tile layer instead of one per layer. The layers are drawn by their sort_id, lowest at the bottom.
Because the image shows every layer, every layer is authorized: the strictest layer decides. One layer that needs credentials makes the whole schema tileset unreachable without them, and a signed-in caller needs read access to every layer in it.
Get the settings
The settings of a schema tileset are read and set on the schema. These requests require an Authorization: Bearer header and are for the super user only. GET returns the values that are in effect, also when nothing has been stored:
- Web App
- HTTP
GET https://api.gc2.io/api/v4/schemas/rockhall/tile HTTP/1.1
Accept: application/json; charset=utf-8
Authorization: Bearer abc123
{
"schema": "rockhall",
"schema_exists": true,
"cache": "sqlite",
"format": "PNG",
"vector_format": "MVT",
"ttl": 86400,
"auto_expire": null,
"meta_size": 3,
"meta_buffer": 0,
"s3_tile_set": null,
"title": "rockhall",
"abstract": "",
"_stored": {
"ttl": 86400
},
"_defaults": {
"cache": "sqlite",
"format": "PNG",
"ttl": 60,
"auto_expire": null,
"meta_size": 3,
"meta_buffer": 0,
"s3_tile_set": null,
"title": "rockhall",
"abstract": ""
}
}
_stored holds only what has been saved, and _defaults what each setting would be if it were not, so a client can tell a set value from a default one.
Change the settings
PATCH merges the given settings into the stored ones. An explicit null removes a setting and returns it to its default. The response is 303 See Other with a Location header pointing back to the settings. The schema must exist (404, SCHEMA_NOT_FOUND), and an unknown field is rejected with 400:
- Web App
- HTTP
PATCH https://api.gc2.io/api/v4/schemas/rockhall/tile HTTP/1.1
Content-Type: application/json
Authorization: Bearer abc123
{
"cache": "mbtiles",
"format": "jpeg_high",
"ttl": 86400,
"meta_buffer": null
}
DELETE on the same path removes the stored settings and answers 204 No Content, also when there was nothing to remove.
Settings are kept when the schema is dropped, as dropping and recreating a schema is routine in an import. GET and DELETE therefore also work for a schema that is gone (schema_exists is then false); PATCH does not.
Cache backends
cache names where the tiles are kept. The same values apply to the cache property of a layer:
| Value | Stores |
|---|---|
sqlite | Tiles in SQLite files. |
disk | Tiles as files in a directory tree. |
mbtiles | Image tiles in one MBTiles file per grid. An MBTiles cache holds images only, so the vector tilesets (.mvt, .json) of the same layer or schema stay in sqlite. |
memcache | Tiles in memcached. |
s3 | Tiles as objects in S3-compatible storage. |
Changing cache or format does not move or remove the tiles already made. They stay in the old backend, unused. Delete the cached tiles before switching if you want them gone.
Delete cached tiles
Tiles that are cached keep the drawing they were made with. After a change of data or styling, delete the tileset's cache:
DELETE https://api.gc2.io/api/v4/mapcache/database/{database}/tileset/{tileset}
This request always needs credentials, whatever the layer's authentication level: a layer tileset needs write access to the layer, and a schema tileset can only be cleared by the super user (403, SUPER_USER_ONLY).
A full delete removes every tile of the tileset:
DELETE https://api.gc2.io/api/v4/mapcache/database/mydb/tileset/rockhall.inductees HTTP/1.1
Authorization: Bearer abc123
A scoped delete removes the tiles within an extent, a zoom range or both. bbox is minx,miny,maxx,maxy in the SRS of the grid, zoom is minzoom,maxzoom or a single zoom level, and grid names the grid (default g20):
DELETE https://api.gc2.io/api/v4/mapcache/database/mydb/tileset/rockhall.inductees?zoom=10,14 HTTP/1.1
Authorization: Bearer abc123
What the answer is depends on the cache backend:
| Delete | Backend | Answer |
|---|---|---|
| Full | sqlite, mbtiles | 200 — the tiles are gone when the request returns. |
| Full | disk | 202 — removed in the background. |
| Full | s3, memcache | 400 — not supported. Use a scoped delete. |
| Scoped | Any | 202 — removed by a background job. |
Seed a cache
A tile is drawn the first time someone asks for it, which makes the first view of an area slow. Seeding draws the tiles ahead of time. It is done with jobs: a job is queued, picked up by a worker within about a minute, and then runs until every tile is made.
Jobs require an Authorization: Bearer header. Sub-users are allowed, and need write access to the layer of the tileset (403, INSUFFICIENT_PRIVILEGES). A sub-user sees their own jobs, the super user every job of the database.
Queue a job
POST queues one job (an object) or several (an array), and answers 202 Accepted with the job. An array is validated and authorized in full before anything is queued:
- Web App
- HTTP
POST https://api.gc2.io/api/v4/tileseeder/jobs HTTP/1.1
Content-Type: application/json
Authorization: Bearer abc123
{
"name": "Seed inductees",
"tileset": "rockhall.inductees",
"grid": "g20",
"zoom_start": 0,
"zoom_end": 12,
"extent_layer": "rockhall.states",
"threads": 2
}
{
"uuid": "c4a3797e-ec6b-4dac-9474-ada9083620f3",
"name": "Seed inductees",
"status": "pending",
"stale": false,
"username": "slash",
"tileset": "rockhall.inductees",
"grid": "g20",
"zoom_start": 0,
"zoom_end": 12,
"extent_layer": "rockhall.states",
"threads": 2,
"host": null,
"pid": null,
"created": "2026-12-04T09:15:00+00:00",
"started": null,
"finished": null,
"heartbeat": null,
"cancel_requested": null,
"error": null,
"_links": {
"self": "/api/v4/tileseeder/jobs/c4a3797e-ec6b-4dac-9474-ada9083620f3"
}
}
The number of tiles grows about four times for every zoom level: zoom 0 to 12 is thousands of tiles, zoom 0 to 18 is millions. Before a job that runs for hours, bound the area with extent_layer, and split the high zoom levels into jobs of their own so they can be cancelled one by one.
Follow a job
GET /api/v4/tileseeder/jobs lists the jobs, newest first. status and tileset filter the list; a value that matches nothing gives an empty array:
GET https://api.gc2.io/api/v4/tileseeder/jobs?status=running HTTP/1.1
Accept: application/json; charset=utf-8
Authorization: Bearer abc123
GET with a uuid returns one job, with log, the tail of the seed output, which the list leaves out. A comma-separated list of uuids returns an array:
GET https://api.gc2.io/api/v4/tileseeder/jobs/c4a3797e-ec6b-4dac-9474-ada9083620f3 HTTP/1.1
Accept: application/json; charset=utf-8
Authorization: Bearer abc123
A job goes from pending to running and ends as succeeded, failed or cancelled. stale is true for a job that is running but has not been heard from for ten minutes: the run or its node is gone, and the job should be cancelled and queued again.
Cancel a job
DELETE with a uuid, or a comma-separated list, asks for the job to stop:
DELETE https://api.gc2.io/api/v4/tileseeder/jobs/c4a3797e-ec6b-4dac-9474-ada9083620f3 HTTP/1.1
Authorization: Bearer abc123
204 No Contentwhen the job was still queued, and is now cancelled, or had already finished.202 Acceptedwith"message": "Stopping"when the job is running. The worker stops it shortly after; read the job until itsstatusiscancelled.
A job that ends as succeeded with cancel_requested set finished before the stop reached it.
Cancelling a job stops the seeding. It does not remove the tiles the job has made; to do that, delete the cached tiles.
Using the SDK
The @mapcentia/gc2-sdk covers the tile side with the Mapcache and Tileseeder classes, and the schema tile settings on the admin client:
import { createCentiaClient, createCentiaAdminClient, Mapcache, Tileseeder } from '@mapcentia/gc2-sdk'
const client = createCentiaClient({ baseUrl, auth: { getAccessToken } })
// A tile URL template for a map library — tiles are fetched by the library, not by the SDK
const mapcache = new Mapcache(client)
const url = mapcache.mapcacheUrl('mydb', 'gmaps/rockhall.inductees@g20/{z}/{x}/{y}.png')
// Delete cached tiles: all of them, or a zoom range
await mapcache.deleteMapcacheTileset('mydb', 'rockhall.inductees')
await mapcache.deleteMapcacheTileset('mydb', 'rockhall.inductees', { zoom: '10,14' })
// Queue a seed job and follow it
const seeder = new Tileseeder(client)
const job = await seeder.postSeedJob({
tileset: 'rockhall.inductees',
grid: 'g20',
zoom_start: 0,
zoom_end: 12,
})
const { status, log } = await seeder.getSeedJob(job.uuid)
const running = await seeder.getSeedJobs({ status: 'running' })
// Cancel: null when it was queued or finished, an object when the job is being stopped
await seeder.deleteSeedJob(job.uuid)
// Schema tile settings
const admin = createCentiaAdminClient({ baseUrl, auth: { getAccessToken } })
const settings = await admin.provisioning.schemaTileSettings.getSchemaTileSettings('rockhall')
await admin.provisioning.schemaTileSettings.patchSchemaTileSettings('rockhall', { cache: 'mbtiles' })
Fields
Schema tile settings
| Field | Description |
|---|---|
cache | The cache backend: sqlite, disk, mbtiles, memcache or s3. |
format | Format of the image tileset: PNG, jpeg_low, jpeg_medium or jpeg_high. |
vector_format | Format of the .mvt tileset. Always MVT — read-only. |
ttl | Seconds a tile stays valid. At least 1; a value below 30 behaves as 30. Default 60. |
auto_expire | Seconds after which an existing tile is drawn again on next access. |
meta_size | Metatile size N: N×N tiles are drawn in one request. 1 to 16, default 3. Image tileset only. |
meta_buffer | Pixels drawn around each metatile and cropped afterwards. 0 to 512, default 0. Image tileset only. |
s3_tile_set | With cache set to s3: the object path segment for this schema. |
title | Shown in the WMTS capabilities. Defaults to the schema name. |
abstract | Shown in the WMTS capabilities. |
schema_exists | false for settings left behind by a dropped schema — read-only. |
_stored | Only the settings that are stored — read-only. |
_defaults | What each setting would be if it were not stored — read-only. |
Seed job
| Field | Description |
|---|---|
tileset | The tileset to seed. Required. |
grid | The name of a grid the tileset has, in practice g20. Required. |
zoom_start | First zoom level to seed. Required. |
zoom_end | Last zoom level to seed. Must be within the zoom levels of the grid. Required. |
name | A label for the job. |
extent_layer | A layer whose features bound the seeded area. The caller must be able to read it. |
threads | Number of seeding threads. Default 1; the server sets the upper limit (4 by default). |
uuid | Server-assigned id — read-only. |
status | pending, running, succeeded, failed or cancelled — read-only. |
stale | true when the job is running but has not been heard from for ten minutes — read-only. |
username | The user who queued the job — read-only. |
created, started, finished, heartbeat, cancel_requested | Timestamps of the run — read-only. |
error | Why the job failed, or null — read-only. |
log | The tail of the seed output. Only when a single job is read — read-only. |
Errors
| Status | Code | When |
|---|---|---|
400 | UNKNOWN_GRID | grid is not a grid of the tileset. The message lists the grids it has. Sending the title GoogleMapsCompatible instead of the name g20 is the usual cause. |
400 | INVALID_REQUEST | A field fails validation, an unknown field was sent, or threads is above the server's limit. |
400 | UNSUPPORTED_BACKEND | A full delete of a tileset cached in s3 or memcache. |
403 | INSUFFICIENT_PRIVILEGES | The caller lacks access to the tileset's layer, or to the extent layer. |
403 | SUPER_USER_ONLY | A schema tileset is cleared, or schema tile settings are read or set, by anyone but the super user. |
403 | A tile is requested from a tileset the caller may not read, or whose name cannot be resolved. | |
404 | SCHEMA_NOT_FOUND | The schema of a schema tileset, or of the tile settings being changed, does not exist. |
404 | An unknown tileset, extent layer or job uuid. | |
429 | TOO_MANY_PENDING | Too many jobs are waiting in the queue. |