2

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 in both server and client. For that reason, in the layer's Tile Caching in Geoserver, I set -1 in both:

  • Expire server cache after n seconds
  • Expire client cache after n seconds

like the following picture:

enter image description here

However, my observation shows that the above only prevents server cache and not client cache, as newly added points will only be shown in my OpenLayers page when any of the following applies:

  1. when the browser is cleared from cache
  2. when the tile is newly received from server (not from cache)

So i dig in more references especially on how to set Tomcat to prevent client from caching. Based on a reference I tried to add ExpiresFilter in the Tomcat's web.xml:

<filter-name>ExpiresFilter</filter-name>
<filter-class>org.apache.catalina.filters.ExpiresFilter</filter-class>
<init-param>
  <param-name>ExpiresByType application/x-protobuf</param-name>
  <param-value>access plus 0 seconds</param-value>
</init-param>

The result is now each tile has new 4 headers in Response Headers: max-age=0, Expires date (with expected value), and 2 more headers; like the following image.

enter image description here

Now the problem: page refresh in browser gets these tiles from browser cache, with HTTP 304 status, and the new 4 headers are now gone; like the following image.

enter image description here

In this situation, any newly added points in my PostGIS table will only appear in OpenLayers when the corresponding tile never gets to browser before.

Question:

  • Is this normal?
  • How to completely prevent browser from caching my PBF vector tile?

My ecosystem:

  • OpenLayers 5.1.3
  • GeoServer 2.13.2 on Tomcat 8.5.32
  • Windows 10 Pro 64-bit
  • PostgreSQL 9.6.1 with PostGIS 2.3
  • browser: FireFox, IE
1

You might be better off avoiding GWC and hitting the WMS end point directly and modifying the HTTP Cache settings on the Layer Publishing tab. I'm not sure if that setting is still used if you go through GWC. Also using vector tiles seems like a lot of work for a rapidly changing data set, you might do better with simple png images.

enter image description here

  • I do not know how to request vector tile to WMS end point. How to do that? Am gonna try it. – Rino Sep 14 '18 at 10:04
  • Do I simply use application/x-protobuf in the FORMAT parameter of WMS request? This WMS reference does not recognize such type as FORMAT. – Rino Sep 14 '18 at 10:17
  • Ian, I tried your suggestion as well: modify Caching Settings in HTTP Seetings (Publishing tab) of the layer, i checked the Response Cache Headers and put 0 seconds cache time. But it does not help as browser still ignores the max-age=0 response header. – Rino Sep 18 '18 at 10:17

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.