Skip to content

Keywords Preload Cronjob

Introduction

Purpose

The purpose of this cronjob is to preload the results for the Shortcodes Asa2 Keywords shortcode. Check section Subsection Keywords for more details.

INFO

This cronjob can only preload keywords shortcodes that have an id parameter set (see id option). Without an id, the shortcode will not appear in the preload list and cannot be refreshed automatically before the cache expires.

Basics

To learn more about cronjobs in general, check out the Cronjobs Intro chapter.

Setup

To learn more about setting up and using ASA2's cronjobs, see the dedicated Cronjobs Setup chapter.

Usage

Name

The internal name of this cornjob is Asa2_Module_Keywords_Cron_Preload.

Therefore, use it with the Cronjobs Setup Serverside execution like this:

php
bash script.sh Asa2_Module_Keywords_Cron_Preload --limit=3

And with Cronjobs Setup Wp Cron Api and ASA2's Cron Wrapper like this:

php
$cronWrapper = new \Asa2\Cron\Wrapper('Asa2_Module_Keywords_Cron_Preload');
$cronWrapper->setOptions([
    'limit' => 3,
]);
$cronWrapper->execute();

REST API Endpoint

The REST API endpoint name of this cronjob is keywords-preload.

Example:

php
https://example.com/wp-json/asa2/v1/keywords-preload/?token=[your-token]&limit=3

Check Cronjobs Setup Rest Api for more details about running ASA2's cronjobs via URL.

Recommendations

The recommended frequency of execution depends on the Options Cache Keywords Preload Threshold setting. By default this is every 15 minutes which means that this cronjob may refresh the keywords results 15 minutes before the cache expires. Therefore, in this case, the cronjob should also be executed at least every 15 minutes.

Options

limit

Limits the amount of keyword shortcodes to be updated. Default is no limit

php
bash script.sh Asa2_Module_Keywords_Cron_Preload --limit=10

pause

Can be used to define a pause in seconds between each process. Can be set globally for all executions with the option options advanced cronjob request pause.

bash
// to set a pause of 2 seconds:
bash script.sh Asa2_Module_Keywords_Cron_Preload --pause=2

php

With the php option, you can tell the ASA2 cronjob what PHP executable it should use to execute the command. With some webhosters the standard command "php" executes an outdated version and there is a special command for each version, e.g. "php74", "php81" or "/opt/php81/bin/php".

Please check which PHP version is required for the use of ASA2 here: https://bit.ly/asa2-php-version

text
bash script.sh Asa2_Module_Repo_Cron_Refresh --limit=10 --php=php74
bash script.sh Asa2_Module_Repo_Cron_Refresh --limit=10 --php=/opt/php81/bin/php

ASA2 - The Amazon Affiliate Plugin for WordPress