mapcache icon indicating copy to clipboard operation
mapcache copied to clipboard

REST Cache not recreated

Open yfr opened this issue 4 years ago • 5 comments

We are using MapCache with the Google Cloud Storage REST cache. We have set an auto_expire to 60 for example. This should recreate the requested tiles after 60 seconds. This does not work. The tiles are never recreated.

In the client, I see these response data. Cache-Control: max-age=60 is always 60.

Date: Tue, 26 Oct 2021 09:50:23 GMT
Server: Apache/2.4.25 (Debian)
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, GET, OPTIONS
Cache-Control: max-age=60
Expires: Tue, 26 Oct 2021 09:51:23 GMT
Content-Length: 3079
Content-Type: image/png

For tests, I switched to a disk cache. There, the recreation works just fine, and the following response is given to the client.

Date: Tue, 26 Oct 2021 09:50:06 GMT
Server: Apache/2.4.25 (Debian)
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, GET, OPTIONS
Last-Modified: Tue, 26 Oct 2021 09:50:07 GMT
Cache-Control: max-age=59
Expires: Tue, 26 Oct 2021 09:51:06 GMT
Content-Length: 3658
Content-Type: image/png

Cache-Control: max-age=60 will count down to the time to recreate the tile. Notice also the Last-Modified header, which is not present in the mapCache response with REST cache.

We are guessing that the Last-Modified from the REST API is not used. Can someone help here? Do we need to add something special to the REST cache config?

yfr avatar Oct 26 '21 11:10 yfr

I'm also trying to grasp how the timestamps work with rest caches (in my case during seeding). Did you find a solution?

barksten avatar May 06 '25 12:05 barksten

I can't find any code at all that reads the header last-modified in static int _mapcache_cache_rest_get(mapcache_context *ctx, mapcache_cache *pcache, mapcache_tile *tile

I assume there should be some code in there that sets tile->mtime in there so that it can compare the date.

Please help!

barksten avatar Jun 09 '25 12:06 barksten

Maybe @tbonfort can chime in about the timestamps/date-headers in rest caches ?

barksten avatar Jun 10 '25 05:06 barksten

they are not implemented, because we assume that rest accesses are relatively slow compared to local accesses, thus making this kind of functionality inefficient (requires either an additional HEAD request to get metadata, or to emit a full GET request who's result will be discarded if the content is too old)

tbonfort avatar Jun 10 '25 07:06 tbonfort

Good to know. We have a S3 storage solution in our own datacenter so the performance is good enough for us.

barksten avatar Jun 11 '25 12:06 barksten