Sure can do! I think it is a really good idea.
But it requires some more thinking. Just maxAge isn’t enough. I would want it to include some type of cache mode. These are the three modes I can think of:
live
Default setting. Resource is considered live, and Resgate expects to gets modifying events/resets whenever the resource changes. This is current behaviour.
static
After sending the resource to the client, Resgate will never send the client any modifying events (even on resets). Combined with maxAge, Resgate may serve it from the cache up until maxAge is reached. If no maxAge is set (or is 0), Resgate will evict it as soon as it has been served to requesting clients.
If Resgate gets a reset for a resource with static mode, it should evict it from the cache without further action.
If Resgate gets a modifying event for a resource with static mode, it may update the cached resource and reset the maxAge timer. However, it will not propagate the changes to any clients. Normally, a service serving a resource with static cache mode should not send modifying events. But if it happens, the behaviour of Resgate should be defined.
autoreset (refetch? or just auto?)
Used in combination with maxAge. Once maxAge is reached, Resgate will behave as if receiving a reset on the resource, and will automatically refetch the resource, compare it with the cached version, and generate events that describes any changes. It will then restart the maxAge timer, repeating the process until no clients are subscribing to the resource. When noone is subscribing, at which time it will simply evict it from the cache.
If Resgate gets a reset event for a resource with autoreset mode, it will directly trigger the refetch and restart the maxAge timer.
If Resgate gets a modifying event for a resource with autoreset mode, it will update the cache and restart the maxAge timer. The event will also be sent to all subscribing clients.
I think that should cover most needs.
In your case, it is perhaps the static that is relevant.
Any comments on this?
Best regards,
Samuel