[metrics-team] Cache advice for Onionoo Node.js API client

Karsten Loesing karsten at torproject.org
Mon Dec 19 08:42:13 UTC 2016


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On 18/12/16 14:33, Luke Childs wrote:
> Hi Karsten,

Hi Luke,

> Thanks for getting back to me :)
> 
>> That sounds correct, assuming you have enough memory to really
>> store responses indefinitely.  Realistically, you could safely
>> discard them after an hour or even sooner.
> 
> Thanks for confirming. Re memory, I've set a configurable limit
> (defaults to 500) on how many responses can be simultaneously
> cached. Once the limit is exceeded the oldest entries will be
> dropped so eating memory shouldn't be an issue.

Sounds good!

>> But I'm more worried of thousands of mobile clients each making a
>> handful of requests than a server caching responses a little less
>> long than it could.
> 
> The issue is the other way round, I'm currently holding the cache
> longer than I should because it always returns a max-age of 300.
> Not really a huge issue for Tor Explorer but if someone builds some
> sort of analytics script with this module I don't want to be
> providing out of date data. Just wanted to confirm the header
> values mean what I think they mean, my web searches returned
> relatively little info.

Well, if an application really needs the latest available data, you
could provide an option to ignore max-age and always send a new
request with If-Modified-Since set.

>> I guess my advice, except for the attempts to answer your
>> questions above, is not to over-engineer the client-side cache
>> for this Node.js module.
> 
> But over-engineering is fun and I have unlimited time :)

Okay!  Though in that case you shouldn't rely on my spotty memory and
instead look at the code or run some experiments. :)

All the best,
Karsten
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org

iQEcBAEBCAAGBQJYV51lAAoJEC3ESO/4X7XBTCUIAJ+VWrvtzYxOqYkhp8PjPojZ
5RDrDoe2G7mWG07XALoLMWFqE14cPTbeTCEM2HByFSeDPqirowQZU92+fW9cbuiS
Hypyu/jUR/1PA0naQRBE4jhOg8pcg3LG7vlQxH1Pz+elikF9laQhC702JVwZ6Tyx
1yeDPSLO4E90c1UMjwuL9PwbwJpfpne79jlJzkkrW/XmqCoZjeQtW6uvY8UmmFwL
9W3fj31T2vcMl1SBb7emUu2MA9sFMa87njPeHzgyDvCtof1lVJZRQhJvG5K5D92u
CH7AoW+BbZWgOgdDG8tQjBn/oqSTBtSDCMY4GV4jyLsoaRZSLN93OH+TKtzOZaA=
=wHPx
-----END PGP SIGNATURE-----


More information about the metrics-team mailing list