2

I published around 1000 layers in geoserver without enabling tile caching for layer.

How to check a cache is enabled for a layer or not?

How to enable tile caching (check box) for a layer under Tile Caching tab using python or Curl?

enter image description here

3

As with all questions relating to a REST API the trick is to make the change once using the GUI and then request that resource from the REST API and see what the required change is.

So you need to find out about a cached layer so goto (e.g.):

http://localhost:8080/geoserver/gwc/rest/layers/topp:states

which returns:

<GeoServerLayer>
  <id>LayerInfoImpl--570ae188:124761b8d78:-7fc0</id>
  <enabled>true</enabled>
  <name>topp:states</name>
  <mimeFormats>
    <string>image/png</string>
    <string>image/png8</string>
  </mimeFormats>
  <gridSubsets>
    <gridSubset>
      <gridSetName>EPSG:900913</gridSetName>
      <extent>
        <coords>
          <double>-1.4998233290893655E7</double>
          <double>2870337.130793682</double>
          <double>-7455049.489182421</double>
          <double>6338174.0557576185</double>
        </coords>
      </extent>
    </gridSubset>
    <gridSubset>
      <gridSetName>EPSG:4326</gridSetName>
      <extent>
        <coords>
          <double>-134.731422</double>
          <double>24.955967</double>
          <double>-66.969849</double>
          <double>49.371735</double>
        </coords>
      </extent>
    </gridSubset>
  </gridSubsets>
  <metaWidthHeight>
    <int>4</int>
    <int>4</int>
  </metaWidthHeight>
  <expireCache>0</expireCache>
  <expireClients>0</expireClients>
  <parameterFilters/>
  <gutter>0</gutter>
</GeoServerLayer>

The key line looks like <enabled>true</enabled> so I would think that for each layer you have you could POST an XML file like that with the layer name changed to that end point.

curl -v -u admin:geoserver -X PUT -H 'content-type: text/xml' -d @test2.xml http://localhost:8080/geoserver/gwc/rest/layers/topp:states

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.