Is Shopify's App Proxy Slowing Down Your Ajax Calls?

Booni3
Tourist
4 0 3

Does anyone know of any limitations (speed wise) of the App Proxies? I have a simple ajax call that is just returning a 2 line JSON text from my server. This is taking almost 600ms.

When I test my server direct, the response is around 30ms.

I am wondering if this is possibly one or a mix of the following:

  • The app proxy takes time to process the request. I am not sure this could account for 550ms though.
  • The location of the server that is making the call to mine is very far away. Although I have speed tested my server from London (my location) and Canada and both are 30 - 60ms in general.
  • Something else on the page is making the proxy request look slow. i.e. Maybe the ajax call is doing some other work, but again I am not sure this could add another ~550ms.

Any advice much appreciated!

Replies 6 (6)

Booni3
Tourist
4 0 3

I have found the answer to this...I should have just tested the proxy directly...

 

The app proxy is slow:

https://www.thehairpinlegcompany.co.uk/apps/stock-info/reviews

Just to reiterate, this is just responding with a cached JSON string. There is no other work happening on the server.

How do the app providers do this when we are able to make calls directly to their servers? i.e. for reviews.io we can call 

https://api.reviews.co.uk

Direct from the browser, and there are no CORS issues. If I try to call my own server, it fails due to CORS, so using the proxy is the only option as far as I can see.

Booni3
Tourist
4 0 3

Final thing I have found, just to help anyone else who comes up against this. If you own the responding server (i.e. are in control of the app code), you can respond with the header:

'access-control-allow-origin' => "*"

 This is not recommended unless the API is intended to be public, but I think in these cases this would be fine. More info here:

https://www.moesif.com/blog/technical/cors/Authoritative-Guide-to-CORS-Cross-Origin-Resource-Sharing...

Mircea_Piturca
Shopify Partner
1547 44 344

I get the same ~600ms response for my own App Proxy. Unfortunately, it is indeed quite slow.

Finally—Add variant descriptions to your products
michiels
Shopify Partner
9 0 3

Same here. I think it fully depends on where Shopify's server is located that's making the connection in relation to where you are hosting the application. It's also possible that if you return "application/liquid" as mime-type it's slower, because Shopify needs to do some additional processing internally before it sends the request back to the browser.

If your app logic can work with directly talking to your application without going through the App Proxy (eg: shop.myshopify.com/apps/yourapp/) then that's your best bet at a speedy result. I'm also working on this.

A few things come to mind to achieve this, depending on the underlying web dev framework you use:

  • Load in pages via a Fetch() request after a first initial "cold" pageload via your app proxy.
  • See if you can generate some kind of authentication token in your proxy app, and then passing it on in every Fetch() request that you do as a Header. For example for identifying the user on Shopify to a user record in your app.
  • Don't return "application/liquid" mimetype if you don't need to use Shopifys layout and liquid engine.
  • Allow CORS on your app to accept connections from Shopify when doing Fetch() requests.

Hope this helps anyone!

viktor_87
Shopify Partner
10 0 2

Hi Michiels,

I'm also doing the same in our app using a proxy, which add almost 1.4 seconds to our usally 30ms response.
I somehow need to validate the request (auth), since it's not a public request.

Any suggestion on how to do that?
I was thinking something like giving each of our customer's an individuel JS script (but since that request isnt AUTH either anyone can download that).
So not sure if there is a way except using the proxy..

NicolasBook
Visitor
2 0 1

Also have the issue.

A simple "hello world" app takes 800ms without liquid processing and 1.4sec with liquid processing.

I'm not sure changing proxy hosting location will change anything as the ping between USA East Coast and Paris (where my proxy is hosted now) is ~100ms.

To establish https communication you need to do 3 back and forth between client and server so it takes 300ms on a total of 1.4sec

It would be good that Shopify improve proxy speed which seems way too slow