rest api – Delay Issue: Using Wget with JSON Endpoint – Need Help Understanding Headers
Question
On a WooCommerce website, I have a REST endpoint created with register_rest_route that returns a JSON response. To perform a routine with a certain frequency and urgency, I have added this instruction:
register_rest_route(SK_SYNC_ENDPOINT.'/v1', '/cron', [
[
'methods' => WP_REST_Server::READABLE,
'callback' => function (WP_REST_Request $request) {
try {
sk_sync_cron();
wp_redirect("<my endpoint address>");
die();
} catch (\Throwable $e) {
return rest_ensure_response(
new WP_REST_Response([
'message' => $e->getMessage(),
'trace' => $e->getTrace()
],
500
)
);
}
},
'permission_callback' => '__return_true',
]
]);
I invoke this function using wget. It works fine, but there is a delay of about two minutes between when the function finishes its job and when wget follows the location header. Why is this happening?
Perhaps wget is waiting for another header since it’s a JSON endpoint?
0
2 months
2023-10-02T06:39:30-05:00
2023-10-02T06:39:30-05:00 0 Answers
0 views
0
Leave an answer