Firebase Performance Monitoring and cached responses

202 views
Skip to first unread message

Mikel Pascual

unread,
Apr 24, 2019, 10:14:09 AM4/24/19
to Firebase Google Group
Hi,

I'm trying to use Firebase Performance Monitoring in order to measure the average response time of a server.
I need mor einformation about how cached responses will be accounted for.

I use okhttp for Android, with the firebase-performance plugin. 
I implemented a local cache in okhttp. For simplicity's sake, imagine that I cache every response for 4 hours: the first request to any endpolint will hit the server once every 4 hours, and it will hit the cache all other times for the next 4 hours.

Say I make 2 requests to `GET /api/cars`:
- the first one hits the server and returns a result in 800ms
- the seconds one hits my local cache and returns a result in 10ms

How will firebase represent this in the network performance stats?
Will firebase say that the average response time for `GET /api/cars` is 405ms? Will firebase say that the average response time for `GET /api/cars` is 800ms?

All in all, is there a way for me to know that when the local cache is not hit, `GET /api/cars` takes 800ms?

Thanks in advance!

Tejas Deshpande

unread,
Jul 18, 2019, 8:54:52 PM7/18/19
to Firebase Google Group
Hi Mikel,

Thanks for reaching out! Recording my response to your question on Slack here for posterity!

If you're using okhttp3.CacheControl for your caching, we will report this as normal network traffic as long as the result returns a valid HTTP Response Code. (If no HTTP Response code is returned, then a network activity isn't reported)

Unfortunately there's no way currently to discern between cached responses vs. full responses (as defined by standard HTTP caching). If that's something you'd like, please do file a feature request and we'll take a look!

A potential workaround would be to disable automatic network request monitoring, and use our manual network request monitoring API!

Thanks,
Tejas

Mikel Pascual

unread,
Jul 19, 2019, 9:59:13 AM7/19/19
to Firebase Google Group
Hi Tejas,

That makes a lot of sense. Thanks for confirming and providing an alternative.

Best,
 MIkel
Reply all
Reply to author
Forward
0 new messages