revoke.cash icon indicating copy to clipboard operation
revoke.cash copied to clipboard

Move onload axios fetching into `getServerSideProps`

Open dawsbot opened this issue 2 years ago • 4 comments

All visitors have an HTTP GET to "https://raw.githubusercontent.com/vasa-develop/nft-tokenlist/master/mainnet_curated_tokens.json" the moment they load. Instead of putting this burden on the browser, you can fetch this once server~client~-side and serve the homepage with this data already filled thanks to getStaticProps.

https://nextjs.org/docs/basic-features/data-fetching/get-static-props

If perhaps this list changes, you can even set a revalidate value

dawsbot avatar Jun 21 '22 17:06 dawsbot

Theoretically it shouldn't matter whether they load this JSON file from GitHub or whether they load it from the Revoke.cash server right, since the payload is the same, just the source would change?

rkalis avatar Jun 22 '22 10:06 rkalis

Exactly, it does not matter where it comes from. But since you already have this code working properly "don't fix what's not broken".

If I opened this as a PR would you be open to merging it? I like to ask before so I don't waste time coding

dawsbot avatar Jun 28 '22 00:06 dawsbot

I still don't really understand what the benefit is. Will it improve load times? How do the load times improve?

rkalis avatar Jun 28 '22 13:06 rkalis

@rkalis so at the moment, the page loads in the browser and then the browser sends out an axios request.

That axios request can be moved server-side and statically cached such that the page load in the browser is the same initially AND no axios request is required.

dawsbot avatar Jun 29 '22 20:06 dawsbot

The "token verification" setup has been updated (improved) in the most recent version of Revoke.cash, so I'll close this issue.

rkalis avatar Jan 04 '23 16:01 rkalis