Max Age (or TTL) of a type or custom resolver

Hi all -

Need some help… I have a custom resolver to a REST API that simply creates a signed URL to images in a secured object store. This is working great. However… these signed URL’s have a shelf life. Currently set to 30 minutes, but can be configured however I want.

Is there a way to set a TTL on a type in my graph? Someway to tell the client that if it’s been longer than “XYZ”, refetch from network and not use cache?

Hi Tom, Unfortunately there is no way to set a TTL on a type in Dgraph.

Could you take a look at this RFC on persisted queries and caching? It might solve your problem or give a way around. There are two related PRs which are close to completion:

  1. feat(Query): Enable persistent queries in dgraph
  2. feat(Query): Add cacheControl directive that adds headers in the response


1 Like

Thank you!

I’m curious. I’m sure some of you are using apollo client. Two easy solutions out of the box are for me to either use a pollInterval. Which, if I understand the docs properly, it’ll execute a network query again if the time since the query happened has reached the value of the poll interval. OR… I can set the fetchPolicy to “cache-and-network” which does a poll of both the cache and the network and updates only what is different. I’m not 100% sure which would be more “expensive” to performance.

Any thoughts or opinions?