The PagePreviews will fire AJAX call every time PagePreviews switch to LINK_DWELL state (more information: https://phabricator.wikimedia.org/T193055#4277206)
Yes, there is always a value in aborting requests:
- from the user side - fewer data sent to the user
- from the service side - there is some value, but it will not make any considerable difference. 99% of summary requests are stored in varnish and never reach restbase. But for remaining 1% aborting request will reduce the server load (first restbase checks Cassandra cache, and if the summary is not present it calls MCS).
We should prevent unnecessary AJAX calls to the service, and additionally, if it's possible - code should abort the ongoing requests. When there is a new interaction code should:
- clear the timed AJAX request
- if there is ongoing AJAX request it should abort it
This change should include a unit test.
QA
- Visit a desktop page in Chrome with many links such as https://readers-web-master.wmflabs.org/wiki/Orange_(colour)
- Open Chrome's DevTools and select the network tab
- Glide the mouse cursor over links at varying rates
AC
- For links that are super quickly passed over, you should observe that no network requests are made to https://en.wikipedia.org/api/rest_v1/page
- For links that are passed over quickly, you should observe that the network request is issued but then canceled; these will show in red in DevTools
- For all links that are lingered upon, page previews should operate as per usual: a network request is issued and then a preview is shown!
Developer Notes
- The current implementation does not store timedAction nor the request object in the state tree, we need to preserve those and on another LINK_DWELL we use these variables to clear the state.
- @phuedx: I expect this number to go down and these numbers to all increase.