-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PWA: Investigate API requests & caching #207
Comments
The service worker gating requests to 15 minute intervals can be eliminated in favor of implementing conditional requests. If the REST API response includes a Refs: |
I like the idea of
@westonruter is there a difference between using |
That's a good question. It seems that
See also relevant discussions on https://core.trac.wordpress.org/ticket/47676 namely it is easier to ensure generate a reliable |
Thanks for explaining that, I think I have a better idea how this all works now :) We only have 3 places that would support being cached by the service worker– tagregator, the live schedule block (session endpoints), and the manifest itself. Of those, tagregator & the live schedule should update as frequently as we set in their code, restricting those to only 15min breaks expectations somewhat. Those endpoints should be cached by the server, so that they're also cached for other clients who request them (browser caching only caches for repeat visits, not distinct users). So… I still wonder if it makes sense to remove the API caching– in #243 we're only making the API request every 5 minutes, and can add server-level caching to make sure these requests don't overload the server. For the sites that don't have the PWA yet, we'll need to make sure those don't cause problems too. We can improve the API to make conditional requests, but that would be a separate task from getting the PWA to a "launch ready" state. @iandunn @coreymckrill what are your thoughts? |
Related: https://make.wordpress.org/core/2019/10/10/filtering-nested-rest-response-_fields-in-wp-5-3/
WFM, just make sure to add the server-layer caching first. |
We only use the embed data to get track information, but we're already fetching that in another API request. We can save some time & bandwidth by omitting the `_embed` request and injecting the data from the tracks request. This potentially cuts the TTFB by 80%, and data downloaded by half. See #207
…TFB (#319) Currently, the sessions endpoint used to fetch sessions for the Live Schedule needs to request the _embed version of the endpoint, which causes a much slower response (around 10s on 2019.us.wordcamp.org). We needed to do this to get the speaker names and category labels, but the rest of the data it outputs is unnecessary. This PR pre-computes speakers and category names, and adds them to the API, so the request can be made for the default endpoint instead. It also restricts the data requested for the live schedule to only the fields needed for display, which drops the size of content downloaded significantly. Fixes #207 by improving API size/response time, API responses are still currently being cached by the SW in the rest-api bucket.
This depends on the API response, but we are attempting to call 3 API endpoints every 60s. Right now this is mitigated by the service worker, so it's only passing through to the server every 15min.
source
API requests themselves can be slow, too:
source
The text was updated successfully, but these errors were encountered: