Thread:Talk:Requests for comment/API Future/Cacheable requests, URLs, and cache purging?

With more usage of the API going into our desktop web, mobile web, and native mobile user interfaces, cacheability is a concern.

As is, if we tried something like this:

/w/api.php?action=mobileview&titles=San_Francisco&maxage=86400&smaxage=86400

there'd be no way for the server-side code to know that that URL needs to be cleared when the 'San Francisco' article changes. You'd get stale results for up to a full day.

The URL isn't very predictable as someone might fudge that maxage around, or decide to use slightly different parameters to change 1% of the data return format, or the parameters might get re-ordered by an HTTP query library and appear in different order in different apps.

If we had a more traditionally structured object-fetch API, we could trivially make things like this HTTP-cacheable:

/w/api/v2/page/parse/San_Francisco /w/api/v2/page/mobileview/San_Francisco

at least for simple data-fetch operations like this.

This wouldn't work for every operation, but we're going to be doing this sort of thing a lot in mobile-land: fetching individual pages' data and then displaying it.