简体   繁体   English

在 React 应用程序中检测用户位置,Fastly 可以与非服务器端渲染的 React 应用程序一起使用吗?

[英]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)该应用程序使用 React,后端为 node.js。目前我们有一些函数调用 api 返回用户的位置。(这需要一段时间)

But, two other options right now is use:但是,现在使用另外两个选项:

  • Geolocation API <--- this might need users' permission?地理位置 API <--- 这可能需要用户的许可?
  • Fastly快速

For Fastly, I am asking对于 Fastly,我问

  • Does it work with non server side rendering app?它是否适用于非服务器端渲染应用程序?
  • For production site, we have fastly set up in route53.对于生产站点,我们已经在route53中快速搭建好了。 but need to ask devops for staging environment.但需要向 devops 询问暂存环境。 ( 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.如果你的应用程序前面有 Fastly,那么是的,你绝对可以使用 Fastly 来提供地理定位信息。

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?明确一点(正如您提到的,您不熟悉 Fastly,更普遍的是“新开发人员”),当我说“面向您的应用程序”时,我的意思是:当客户端(例如用户的 web 浏览器)发出https请求时://yourapp.com/ ,请求是否首先通过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 会将请求代理到您的应用程序,并且您通过 Fastly 发送回客户端的任何数据都可能会被缓存,以便更快地为您的所有用户发出未来请求(这是 Fastly 提供的众多功能之一) .

Fastly has lots of products, but for your primary purposes there are two platform services Fastly offers: Fastly 有很多产品,但为了您的主要目的,Fastly 提供了两个平台服务:

  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).基于 Varnish/VCL 构建的内容交付 (CDN)(如果您的运营团队已经进行了 Fastly 设置,那么这很可能就是他们所拥有的)。
  2. Compute@Edge which is built upon WebAssembly. Compute@Edge 基于 WebAssembly 构建。

I would highly recommend reading the following resources to understand more about the Fastly platform options:我强烈建议阅读以下资源以了解有关 Fastly 平台选项的更多信息:

As far as using Fastly to handle geolocation information, I'll point you to the following resources:至于使用 Fastly 处理地理定位信息,我将为您指出以下资源:

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.我还建议尝试一下 https://fiddle.fastly.dev ,它让您可以使用 VCL 或任何受支持的 Compute@Edge 语言来测试想法,而无需真正的 Fastly 服务设置。 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).最后,您还可以阅读https://www.integralist.co.uk/posts/fastly-varnish/的前半部分,其中涵盖了 Fastly 使用 Varnish/VCL 的一些基础知识(但我建议阅读官方参考资料,上面链接,第一个)。

Any other questions, then please feel free to reach out to support@fastly.com who will be happy to help.如有任何其他问题,请随时联系 support@fastly.com,我们将很乐意为您提供帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我们如何使用 React Router 4 将客户端渲染 React js 应用程序转换为服务器端渲染? - How we can convert client side rendering react js app to server side rendering using react router 4? 我们可以在同一个反应应用程序上设置客户端和服务器端渲染吗? - Can we setup client and server side rendering on same react app? 将服务器端渲染添加到现有的React应用程序 - Adding server side rendering to an existing React app create-react-app服务器端渲染 - create-react-app Server Side Rendering React可以用于服务器端渲染。 这意味着什么? - React can be used on server side rendering. What does that mean? 可以在create-react-app服务器端使用react-loadable吗? - Can react-loadable be used in create-react-app server-side? 服务器端渲染的React应用程序因加载而崩溃 - React app with Server-side rendering crashes with load 需要建议将React应用程序转换为使用服务器端渲染 - Need advice converting React app to use server side rendering 用于服务器端渲染的 create-react-app - create-react-app for server-side rendering 在具有服务器端呈现的React PWA中缓存应用程序shell - caching app shell in a React PWA with Server-Side rendering
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM