SearchVue currently performs requests against MW's action API, combining data from multiple modules.
As indicated in T307736#8348021, those are not cached.
We should create a new rest.php entrypoint from within SearchVue for the article data.
See https://www.mediawiki.org/wiki/API:REST_API/Extensions for instructions about setting up a new Rest API endpoint.
Instead of reimplementing all logic, this new API can simply wrap around the current request (which would now be performed on the backend) and filter out any data not needed.
Essentially something along the lines of:
$request = new FauxRequest( [ 'action' => 'query', 'format' => 'json', 'titles' => $title, 'prop' => 'pageimages|pageprops|cirrusdoc', 'formatversion' => 2, 'pithumbsize' => 400, 'pilicense' => 'free', 'piprop' => 'thumbnail|name|original', 'cdincludes' => 'heading' ] ); $api = new ApiMain( $request ); $context = new DerivativeContext( RequestContext::getMain() ); $context->setRequest( $request ); $api->setContext( $context ); $api->execute(); $response = $api->getResult()->getResultData( [], [ 'Strip' => 'all' ] ); // @todo filter unused fields from response (if any)
(See https://github.com/wikimedia/mediawiki-extensions-MediaSearch/blob/master/src/Special/SpecialMediaSearch.php#L548 for something similar)
Variables for the page endpoint are:
- page title
- elastic field from which the search snippet originated (unused ATM, but will need this for T316397)
So that endpoint could be something like rest.php/searchvue/v0/page/{page_title}/{snippet_field}