Seravo / seravo-plugin

Enhances WordPress with Seravo specific features and integrations
https://seravo.com/
GNU General Public License v2.0
37 stars 16 forks source link

Review number of SWD API calls #304

Closed ottok closed 4 years ago

ottok commented 4 years ago

While profiling the front page of seravo.com for slowness I noticed that the Seravo Plugin did 3 API calls to the domains end-point: image

This was on the front page while logged into wp-admin. image

I understand that the shadow data might be needed in this view to be able to render the shadow switcher, but why 3 calls to the domains API for this purpose? Seems like a bug. Please investigate.

ypcs commented 4 years ago

By looking at syslogs at servers there is also lots of HTTP requests to /domains. Should we use transients to reduce number of queries? Domains wont change all the time, retrieve data only once in 5 minutes or something?

ottok commented 4 years ago

Primary solution is not to do that many calls in the first place. I doubt the code is correct if 3 API calls are done in a row. Secondary solution is to cache it for a short time.

Let's wait until @JoosuaKoskinen has time to look into this.

JoosuaKoskinen commented 4 years ago

I took a quick look and it's because domains are queried for each shadow individually (wp-palvelu.fi has 3 shadows). This should be possible with one call only. Will work on a fix tomorrow.

SWD API is quite fast but should the results be cached for a while to reduce the amount of requests?