revoke.cash
revoke.cash copied to clipboard
Move onload axios fetching into `getServerSideProps`
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
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?
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
I still don't really understand what the benefit is. Will it improve load times? How do the load times improve?
@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.
The "token verification" setup has been updated (improved) in the most recent version of Revoke.cash, so I'll close this issue.