brave-intl / bat-ratios

a server to cache and serve up exchange rates between currencies
3 stars 3 forks source link

Add Cache-Control header to etherscan tokeninfo passthrough requests #158

Closed nvonpentz closed 1 year ago

nvonpentz commented 1 year ago

If the query params include query.module='token' && query.action='tokeninfo', then set a Cache-Control header of 14 days.

nvonpentz commented 1 year ago

Works on dev - Cache-Control set for the tokeninfo query string:

➜  bat-ratios git:(cache-control) curl -I https://ratios.rewards.brave.software/v2/etherscan/passthrough\?module\=token\&action\=tokeninfo\&contractaddress\=0x0d8775f648430679a709e98d2b0cb6250d2887ef
HTTP/2 200
content-type: application/json; charset=utf-8
x-powered-by: Express
cache-control: public, max-age=604800
etag: W/"2ed-MTC9QpCkIjnj/cELuPHhNXg0o74"
accept-ranges: bytes
date: Fri, 21 Apr 2023 13:51:31 GMT
via: 1.1 varnish
age: 0
x-served-by: cache-lga21940-LGA
x-cache: MISS
x-cache-hits: 0
x-timer: S1682085091.145630,VS0,VE714
vary: Authorization
content-length: 749

Not set for the gas oracle

➜  bat-ratios git:(cache-control) curl -I https://ratios.rewards.brave.software/v2/etherscan/passthrough\?module\=gastracker\&action\=gasoracle

HTTP/2 200
content-type: application/json; charset=utf-8
x-powered-by: Express
etag: W/"126-DKXSzAmftMA/mpjgtAL4CxebQwE"
accept-ranges: bytes
date: Fri, 21 Apr 2023 13:51:38 GMT
via: 1.1 varnish
age: 0
x-served-by: cache-lga21942-LGA
x-cache: MISS
x-cache-hits: 0
x-timer: S1682085098.717950,VS0,VE715
vary: Authorization
content-length: 294