1

I need to publish a geometry table (in PostGIS) as a layer of vector tiles (in PBF format) in GeoServer. As the table is dynamically written by a production web app, i need to set the layer's caching as disable. I got a hint that this could be done by editing the geowebcache.xml, specifically with <expireCacheList> and <expireClientsList> tags, using the special value -1 (that means no-cache).

What i can not find anywhere is a a real example of configuring this in the geowebcache.xml. The following is my default file (of GeoServer 2.13.2 on Apache Tomcat 8.5):

<?xml version="1.0" encoding="utf-8"?>
<gwcConfiguration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns="http://geowebcache.org/schema/1.8.0"
  xsi:schemaLocation="http://geowebcache.org/schema/1.8.0 http://geowebcache.org/schema/1.8.0/geowebcache.xsd">
  <version>1.8.0</version>
  <backendTimeout>120</backendTimeout>
  <!--
  <serviceInformation>
    <title>GeoWebCache</title>
    <description>GeoWebCache is an advanced tile cache for WMS servers. It supports a large variety of protocols and
      formats, including WMS-C, WMTS, KML, Google Maps and Virtual Earth.</description>
    <keywords>
      <string>WFS</string>
      <string>WMS</string>
      <string>WMTS</string>
      <string>GEOWEBCACHE</string>
    </keywords>
    <serviceProvider>
      <providerName>John Smith inc.</providerName>
      <providerSite>http://www.example.com/</providerSite>
      <serviceContact>
        <individualName>John Smith</individualName>
        <positionName>Geospatial Expert</positionName>
        <addressType>Work</addressType>
        <addressStreet>1 Bumpy St.</addressStreet>
        <addressCity>Hobart</addressCity>
        <addressAdministrativeArea>TAS</addressAdministrativeArea>
        <addressPostalCode>7005</addressPostalCode>
        <addressCountry>Australia</addressCountry>
        <phoneNumber>+61 3 0000 0000</phoneNumber>
        <faxNumber>+61 3 0000 0001</faxNumber>
        <addressEmail>john.smith@example.com</addressEmail>
      </serviceContact>
    </serviceProvider>
    <fees>NONE</fees>
    <accessConstraints>NONE</accessConstraints>
  </serviceInformation>
  -->
  <gridSets>
    <!-- Grid Set Example, by default EPSG:900913 and EPSG:4326 are defined -->
    <!--
    <gridSet>
      <name>EPSG:2163</name>
      <srs>
        <number>2163</number>
      </srs>
      <extent>
        <coords>
          <double>-2495667.977678598</double>
          <double>-2223677.196231552</double>
          <double>3291070.6104286816</double>
          <double>959189.3312465074</double>
        </coords>
      </extent>
      <scaleDenominators>
        <double>25000000</double>
        <double>1000000</double>
        <double>100000</double>
        <double>25000</double>
      </scaleDenominators>
      <tileHeight>200</tileHeight>
      <tileWidth>200</tileWidth>
    </gridSet>
    -->
  </gridSets>

  <layers>
    <!--
    <wmsLayer>
      <name>topp:states</name>
      <mimeFormats>
        <string>image/gif</string>
        <string>image/jpeg</string>
        <string>image/png</string>
        <string>image/png8</string>
      </mimeFormats>
      <gridSubsets>
        <gridSubset>
          <gridSetName>EPSG:2163</gridSetName>
        </gridSubset>
      </gridSubsets>
      <parameterFilters>
        <stringParameterFilter>
          <key>STYLES</key>
          <defaultValue>population</defaultValue>
          <values>
            <string>population</string>
            <string>polygon</string>
            <string>pophatch</string>
          </values>
        </stringParameterFilter>
      </parameterFilters>
      <wmsUrl>
        <string>http://demo.opengeo.org/geoserver/topp/wms</string>
      </wmsUrl>
    </wmsLayer>

    <wmsLayer>
      <name>raster test layer</name>
      <mimeFormats>
        <string>image/gif</string>
        <string>image/jpeg</string>
        <string>image/png</string>
        <string>image/png8</string>
      </mimeFormats>
      <wmsUrl>
        <string>http://demo.opengeo.org/geoserver/wms</string>
      </wmsUrl>
      <wmsLayers>nurc:Img_Sample</wmsLayers>
    </wmsLayer>

    <wmsLayer>
      <name>img states</name>
      <metaInformation>
        <title>Nicer title for Image States</title>
        <description>This is a description. Fascinating.</description>
      </metaInformation>
      <mimeFormats>
        <string>image/gif</string>
        <string>image/jpeg</string>
        <string>image/png</string>
        <string>image/png8</string>
      </mimeFormats>
      <gridSubsets>
        <gridSubset>
          <gridSetName>EPSG:4326</gridSetName>
          <extent>
            <coords>
              <double>-129.6</double>
              <double>3.45</double>
              <double>-62.1</double>
              <double>70.9</double>
            </coords>
          </extent>
        </gridSubset>
      </gridSubsets>
      <expireCacheList>
        <expirationRule minZoom="0" expiration="60" />
      </expireCacheList>
      <expireClientsList>
        <expirationRule minZoom="0" expiration="500" />
      </expireClientsList>
      <wmsUrl>
        <string>http://demo.opengeo.org/geoserver/wms</string>
      </wmsUrl>
      <wmsLayers>nurc:Img_Sample,topp:states</wmsLayers>
      <transparent>false</transparent>
      <bgColor>0x0066FF</bgColor>
    </wmsLayer>
    -->
  </layers>
</gwcConfiguration>

Do i:

  1. simply put the <expireCacheList> and <expireClientsList> out of comment?

  2. Or do i need to make a whole <wmsLayer> block for that specific layer (from <name>, <metaInformation>, <mimeFormats>, <gridSubsets>, all the way down to <bgColor>), that specifies <expireCacheList> and <expireClientsList>?

1

I don't believe you set these settings in the geowebcache.xml file when using GWC within GeoServer. That is only if you are using GeoWebCache as a standalone installation. You should use the settings on the 'Tile Caching' tab for each layer in the GeoServer. If you uncheck the 'Create a cached layer for this layer' you will definitely not be returning cached data but you might still have some trouble with the client side caching (i.e. in a web browser).

  • I tried it. If the Create a cached layer for this layer is unchecked, GeoServer does not serve the PBF vector tile at all, and GeoServer response request from my OpenLayers page with HTTP 400. – Rino Aug 24 '18 at 6:39
  • Hi, the expireClient options are also set on the 'Tile Caching' tab so you could try those instead. I forgot that we have enabled the WMS/Tile cache integration so we would just use the WMS url enpoints. The result is that we get an uncached response if we uncheck the option you describe. Of course without that option I guess you would get a 400. – Paul Wittle Aug 29 '18 at 16:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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