WP REST API route request explain

Maybe can someone explain or show additional info about “WP REST API route request” from beginning to the end.

Main questions, how handle this request in most earlier stage. For example for ajax requests, is second check:

if (defined('DOING_AJAX') && DOING_AJAX) { /* it's an AJAX call */ }

What check can be most fast to handle rest api request?

Main my approach in app logic, after route request init, immediately check what route type was and do we have saved by current request result with wp standart set_transient function. If it is, grab result directly from database (transients), and don’t generate expansive in time new object result.

So more in global view of logic:

  1. Getted request.
  2. In functions.php detected that request and disabling loading some
    stuff for speed up this.
  3. In some “rest_api” action we handle type | url of request and
    checking for availability of transients.
  4. If is transient result, immediately return it without generating
    expansive in cpu and time answer from server.

0

Leave a Comment