Fix max-age (expires) times for overlay layers
I recently discovered that the way I'm specifying auto_expires
for overlay/border layers is actually causing browsers to only cache the tiles for 5 minutes. Here's the message I posted on slack:
MapCache is setting the cache age just fine, but I have it misconfigured for overlay layers. MapCache has two parameters that can be set:
* expires: Specify HTTP response header expiration age. Defaults to 5 minutes.
* auto_expire: Specify the age that a tile can be in the cache before the cache needs to be refreshed (this is the tile cache, not the browser cache). If specified, it overrides expires for the HTTP header information. If set to 0 (False), the default, tiles in the tile cache never expire.
The problem is that for overlay layers I only set auto_expire and set it to 0, but 0 also means False so in this case it never overrides expires. This results in overlay layers being produced with a browser cache age of 5 minutes. Image layers on the other hand have auto_expire set to 7 days so it all works as expected. This means overlays, which never change, are only cached for 5 minutes. Image layers which don't change either, but are more likely to change, are cached much much longer.
There are two possible fixes:
- Set
auto_expires
to a non-zero value. - Add a separate option for specifying the expiration (
expires
) as something long.
I'm tempted to do option 2 so we can control the two behaviors separately if needed.