thislooksfun/snoots

Add ability to introduce a client side cache

npomfret opened this issue · 2 comments

Feature Description

I'd like to locally cache some pages so that I'm not hammering reddit for the same data again and again, especially while testing.

I understand that GOT has hooks for providing your own. Could this be exposed in the options used to create the client?

https://github.com/sindresorhus/got/blob/HEAD/documentation/cache.md

Ideally, the cached requests would not count towards any in-built rate limiter (if there is one).

That's not a bad idea in theory, but it has two problems:

  1. I'm going to be switching away from got as soon as Node's native fetch is stable (#45), so I don't want to rely on their implementation.
  2. It seems that Reddit sets the HTTP cache-control header to disallow any caching anyway, so we can't use any HTTP-compliant caching scheme, and trying to build our own raises the question "when to invalidate?", which is a really hard question to answer well.

Given these issues I'm going to put this on a very back burner. Maybe I'll get to it someday, but don't hold your breath. In the meantime if you really need this functionality feel free make your own Gateway subclass that implements caching, and maybe even submit it as a PR.

ok, thanks