Does WP REST API cache internally executed (rest_do_request) requests?

Does WP REST API cache internally executed requests? No it does not, not out of the box. CDNs and caching plugins can and do interfere however, especially for unauthenticated REST requests. As an example to demonstrate this with hard results and test my own conclusion I added a random number generator to my site: https://tomjn.com/wp-json/tomjn/v1/random … Read more

How to create a transient that persists the data for the whole duration of the expiration, even when object cache is enabled?

I eventually used a combination of update_option and WP Cron: // Create the option. update_option(‘foo’, ‘bar’, false); /** * Schedule it to be deleted one week from now. * * @param int Expiration timestamp * @param string Hook that will be invoked * @param string Params to send to the hook callback */ wp_schedule_single_event( time() … Read more

Homepage not loading correctly, only after refreshing

You can change your current theme to storefront and check whether the scripts and styles are properly enquequed. use this format to enqueque style and scripts and inspect the code for debugging class yourPluginName { public function __construct() { add_action(‘wp_enqueue_scripts’, array($this, ‘enqueue’)); } public function enqueue() { wp_enqueue_script(“jquery”); wp_enqueue_script(‘my-js’, plugins_url(‘/script.js’, __File__)); wp_enqueue_style(‘my-theme’, plugins_url(‘/style.css’, __File__)); }

Cache a number of responses from external json feeds?

$body = get_transient( ‘my_api_response_value’ ); if ( false === $body ) { $url=”https://api.myapi.com/chart?ticker=” . $ticker . ”; $response = wp_remote_get($url); if (200 !== wp_remote_retrieve_response_code($response)) { return; } $body = wp_remote_retrieve_body($response); set_transient( ‘my_api_response_value’, $body, 5*MINUTE_IN_SECONDS ); } $formatted_json = json_decode($body, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); We submit a request at the beginning because the transient doesn’t … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)