简体   繁体   中英

Detect user location in React app, Can Fastly be used with Non Server Side Rendering react app?

this is my first task of detecting users' geo locations and I am a fairly new dev. The app uses React and backend is node.js. Currently we have some functions that calls an api which returns users' locations.( this takes a while)

But, two other options right now is use:

  • Geolocation API <--- this might need users' permission?
  • Fastly

For Fastly, I am asking

  • Does it work with non server side rendering app?
  • For production site, we have fastly set up in route53. but need to ask devops for staging environment. ( I got this info from others but do not know what that means )
  • Can someone even explains to me how fastly work and what needs to be set up? Basically any information is appreciated. I do not know what should be googled to find out the answers. Thanks.

If you have Fastly fronting your app, then YES you can definitely use Fastly to provide geolocation information.

Just to be clear (as you mentioned you were unfamiliar with Fastly and more generally are a "new dev"), when I say "fronting your app" I mean: when a client (eg a user's web browser) makes a request for https://yourapp.com/ , does the request first get routed through Fastly? If it does, then Fastly will proxy the request through to your app and any data you send back through Fastly to the client will likely be cached to make future requests for all your users much quicker (this is one of the many functions Fastly provides).

Fastly has lots of products, but for your primary purposes there are two platform services Fastly offers:

  1. Content Delivery (CDN) which is built on Varnish/VCL (if your ops team already has Fastly setup then this is likely what they have).
  2. Compute@Edge which is built upon WebAssembly.

I would highly recommend reading the following resources to understand more about the Fastly platform options:

As far as using Fastly to handle geolocation information, I'll point you to the following resources:

Also search the following page for references to "geolocation" as there are quite a few 'examples' that you might be interested in:

I would also suggest having a play around with https://fiddle.fastly.dev which let's you use either VCL or any of the supported Compute@Edge languages to test out ideas without needing to have a real Fastly service setup. This will give you a chance to trial out some geolocation code.

Lastly, you can also have a read through the first half of https://www.integralist.co.uk/posts/fastly-varnish/ which covers some basics about Fastly's use of Varnish/VCL (but I'd suggest reading the official references, linked above, first).

Any other questions, then please feel free to reach out to support@fastly.com who will be happy to help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM