Last modified: 2014-02-12 23:53:52 UTC
On every page view we do GET /w/api.php?action=query&format=json&titles=Barack+Obama&prop=info&inprop=watched HTTP/1.1 It's absolutely unnecessary as pages aren't cached for logged-in users so we can output the watched status in the page HTML.
I don't see what this gives us apart from more code fragmentation. Is this really a performance hit to the server? Remember we dynamically load pages on beta and when this happens we will need to do an ajax call anyway to get watchlist status. This would mean we would need to special case against the first page load to do something different. I worry this will lead to clumsy javascript code. It's worth noting that currently we don't show the watchlist star to users with older phones that we don't serve javascript to. It might be worth rendering the star in the html and making it a simple form post so that these users can still watch pages. This might be a good motivation to doing things this way. Also surely we should be getting to a state where we __can__ cache logged in users page - we should be working towards that and I feel like this works against that direction... no? Thoughts?
Also to clarify "On every page view we do GET" should actually read "On every page view where a user is logged in we do a GET"
An unnecessary roundtrip to api.php should be avoided if at all possible, its more expensive to invoke than it should be. Logged in users do not generate api.php?action=query&prop=info&inprop=watched on every page view, and I think MobileFrontend should strive not to add additional request overhead vs. the standard site. +1 to Max's approach here.
Note that ResourceLoader allows module responses to be embedded in the page HTML, for the purposes of improving the performance of logged-in page views. This is used, for example, to send user preferences. We're not currently working towards HTTP caching of logged-in page views.
Thanks Asher and Tim for the input. Using ResourceLoader in this way seems to be the way to go.
https://gerrit.wikimedia.org/r/51604
https://mingle.corp.wikimedia.org/projects/mobile/cards/413