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:
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:
- when the browser is cleared from cache
- 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
<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:
Expires date (with expected value), and 2 more headers; like the following image.
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.
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.
- Is this normal?
- How to completely prevent browser from caching my PBF vector tile?
- 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