Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Last-Modified" header for new tiles is Thu, 01 Jan 1970 00:00:00 GMT and it breaks reloading tiles in certain conditions #1283

Open
vitalus opened this issue Jun 25, 2024 · 0 comments

Comments

@vitalus
Copy link

vitalus commented Jun 25, 2024

Interesting behavior.

Let's say, there is an OpenLayers app working with vector tile layer.

geowebcache.xml has this settings:

      <expireClientsList>
        <expirationRule minZoom="0" expiration="-1"/>
        <expirationRule minZoom="8" expiration="-1"/>
      </expireClientsList>

So, GeoServer sends header: Cache-Control: no-cache.

Application is loaded and OpenLayers requests vector tile that is already in GWC cache. Let's assume it has header Last-Modified: Tue, 25 Jun 2024 00:55:00 GMT

Now, I modify geometry (by editing tools, geometry is loaded in custom way from backend API) and press SAVE button. What happens next:

  1. Geometry is sent to custom backend

  2. Backend persists geometry to Postgre database

  3. Backend calls REST API in GeoServer to truncate GWC cache for underlying layer in a given area (BBOX of feature geometry + some buffer)

  4. Related vector tiles are deleted from file system by GeoServer

  5. When all backend tasks are completed, Javascript logic (front-end) calls Layer.refresh() on layer with vector tiles.

  6. OpenLayers starts to send requests to GeoServer with header: If-Modified-Since: Tue, 25 Jun 2024 00:55:00 GMT

  7. GWC does not find related tiles and generates them. But it sends a response with header: Last-Modified: Thu, 01 Jan 1970 00:00:00 GMT
    which makes browser to ignore loading fresh tiles. Basically it's a response 304 from GeoServer..

Vector tiles in OpenLayers are not reloaded from GeoServer (while they are generated by GeoServer during this request) and previous tiles from browser cache are extracted..

So, in a result OL renders old tiles from browser cache (because of 304 response).

All these is because for some reason GeoServer sends Last-Modified: Thu, 01 Jan 1970 00:00:00 GMT header for new tiles being generated which is earlier than If-Modified-Since: Tue, 25 Jun 2024 00:55:00 GMT in a request.

And only on second Layer.refresh() browser gets a response 200 with fresh tiles because on second attempt GeoServer sends actual timestamps of files (tiles are saved in file system).

I believe if GeoServer would first save new tiles to store (file system) and sens real timestamps in "Last-Modified" header then OpenLayers would successfully refresh tiles from first call Layer.refresh().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant