x

Square Online: Removing images from API call on paginated products view

Preface

 

I initially posted this as a thread on the SquareUp developer forums, which you can find here: https://developer.squareup.com/forums/t/4008

 

I am reposting it here since this may be the more relevant location to discuss Square Online performance issues.

 

 

The Problem

 

I’m trying to help a client debug intermittent slowdowns their customers are experiencing on their Square Online page when viewing the paginated product page grid, such as all products in a specific category.

 

They have several hundred items, organized into many categories, and each with many modifiers and options. When exported to an excel spreadsheet, their Square Items library contains 18,500 unique Item Tokens. Many items have 6 or more product images.

 

An XHR request to the products API is fired off on pages with the paginated products grid view and will frequently (but not consistently) take 20-50 seconds to resolve. It seems that when the response is not cached, the complexity of the items library may be causing the server to really struggle generating the reply.

 

I want to emphasize that this is not a connection or client-side issue. I’ve verified this on several different machines and network locations with very solid connections.

 

The API call for viewing the paginated view of products in a given category generally looks like this:

https://cdn5.editmysite.com
    /app/store
    /api/v17/editor
    /users/{USERID}
    /sites/{SITEID}
    /products
    ? page = 1 
    & per_page = 60 
    & sort_by = category_order
    & sort_order = asc
    & categories[] = {CATEGORYID}
    & include = images, media_files
    & excluded_fulfillment = dine_in

 

I noticed that if I remove the ‘images’ include in the query string, the resulting reply is about 20% of the original size. For example in a specific case I’ve logged (see more at bottom of post), for the product page of a category with 9 items the response decreased from 155,292 characters to 31,742 characters when removing the images from the query string include.

 

As best as I can tell the images data is completely unused in the paginated grid view - the images displayed there use the ‘thumbnails’ object which is included even when images is not specified in the query string.

 

While it is definitely possible that the huge slowdown when the server’s API response is not cached is due to hitting some edge case due to the complexity of the Items Library of this store, I’d like to at least try to see if having the API response be less verbose would have a noticeable impact on its overall response time.

 

Cutting down the response data by a factor of 5 seems like it would be worth a shot.

 

 

The Question

 

Is there any way that the default Square Online products grid view could be modified to not request images, or potentially use a less verbose response format? Is a Square vendor relying on the default Square Online UI (as opposed to investing in rolling their own frontend) just SOL?

 

Alternatively, are there any recommendations for how to debug these kinds of API slowdowns? Is there any Square technical support I could reach out to help identify what is actually causing the API to respond so abysmally slow for this specific store and Item Library?

 

Best,

Johannes

 

 

 

PS: Below I’ve included a full log showing the aforementioned slowdown

 

Example Log

 

I captured the following network log as I clicked on a category that contains 9 items total, which I exported using the ‘Export HAR file…’ option in the Google Developer tools Network tab: https://gist.githubusercontent.com/JohannesMP/8dca677b9307dd20c6dbb7437b0282bf/raw/858f30ea3dcdf79c8...

 

To view for reference you can download the file as plaintext with a .har extension and the ‘Import HAR file…’ option in the Chrome Developer tools Networks tab.

JohannesMP_0-1634882847347.png

 


 

The API call to retrieve the product information for the 9 items for the page’s grid view took 23.28 seconds to complete, was 12.2kB in size and 155293 characters.

 

Here is the raw JSON response, formatted for readability: 

https://gist.githubusercontent.com/JohannesMP/8dca677b9307dd20c6dbb7437b0282bf/raw/9cd43cd626bd71959...

 

460 Views
Message 1 of 1
Report
0 REPLIES 0