gitbeaker icon indicating copy to clipboard operation
gitbeaker copied to clipboard

Support for etag Caching

Open octopotato opened this issue 5 years ago • 4 comments

Description Gitlab supports etag cachine which we'd like to leverage. For web apps, this is very useful since it allows clients to cache repositories/branches/etc on the client and only get the new data if it changes instead of constantly polling.

Proposal Requires an investigation but likely will change some of the interfaces/responses. Could also add new methods like xxxWithCaching. For example, api.projects().allWithCaching(..)... Alternatively, add another optional parameter to existing methods for etag.

octopotato avatar Jun 03 '19 19:06 octopotato

Could probably just modify the instantiation object as to not change the interface too much. Wouldn't be too difficult to implement, but would really eat up memory no?

jdalrymple avatar Jun 03 '19 19:06 jdalrymple

I was thinking more of letting the client's decide what to do. I gave it some more thought last night and I think a way to get the headers back (as well as set additional header values) is really all we need (at least for our use case). That way clients can decide what to do with that information. But going that route it does require some small changes since when data hasn't changed the response comes back as a 304 with no data.

octopotato avatar Jun 04 '19 16:06 octopotato

Wouldn't be too hard though! Sounds like a cool feature too. If you get the chance see if you can tinker with it. Ill try and set some time aside this weekend to look at it myself.

jdalrymple avatar Jun 04 '19 17:06 jdalrymple

More questions about this feature! How do the requests change to use the caching feature? is it a different url? or an additional header. I can't seen to find an example 😕

jdalrymple avatar Aug 13 '19 15:08 jdalrymple

Closing for now! If there is still interest in this functionality, ill reopen

jdalrymple avatar Apr 26 '23 18:04 jdalrymple