2

Right now client-side caching appears to be working with its default configuration, using the following headers:

Response
HTTP/1.1 200 OK
Content-Type: image/png
Content-Disposition: inline; filename=States-US_HistCounties.png
Transfer-Encoding: Identity
Cache-Control: no-cache
ETag: 29e79cc2e4fe182660936eb2ff1f5aab
X-Frame-Options: SAMEORIGIN
Last-Modified: Thu, 20 Dec 2018 17:30:02 GMT
geowebcache-tile-bounds: -7924991.091503907,5117000.420810547,-7915207.151884766,5126784.360429689
geowebcache-crs: EPSG:900913
Server: Jetty(9.2.13.v20150730)
geowebcache-gridset: EPSG:900913
geowebcache-cache-result: HIT
geowebcache-tile-index: [1238, 2571, 12]
geowebcache-layer: xxx:xxx

I have found that the downside to this caching mechanism is that an extra request gets made back to the server to check if anything has changed since the last request(?) for this layer.

My goal is to not have that extra HTTP request, and instead immediately serve the cached content. This particular layer is static and will never change once cached.

Is there any way to configure that on a layer-by-layer level? I was thinking something along the lines of Cache-Control: public might be useful.

I have browsed the GeoWebCache documentation and tried to google articles, but I have been unable to find anything that talks about this.

2

Here's what I found out that works for me so far:

  1. Log into your Geoserver admin panel.
  2. Go to Tile Caching > Tile Layers.
  3. Click on the layer you wish to customize the cache settings for.
  4. Scroll down to the HTTP Settings section.
  5. Check "Response Cache Headers".
  6. Enter a huge value for the cache time, like 99999999.
  7. Click on the "Tile Caching" tab at the top.
  8. Change the two "Expire xxx cache..." input fields to fit your needs. In my case I set them both to 99999999.

This seems to eliminate the extra check request otherwise observed, while letting you configure it on a layer-by-layer basis. Checking the request headers we now see:

Summary
URL: xxxx
Status: 200 OK
Source: Disk Cache

Request
No request, served from the disk cache.

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.