Choose Once Per Page Request or Every Occurrence for a QCDR PHP Token

Every PHP Token has an Execution mode. Once per page request — Recommended runs the PHP one time on its first actual use in the Joomla request and reuses the captured output. Every occurrence — Advanced deliberately reruns the PHP at each actual Token location or eligible Rule match.

This choice is primarily about repeated code execution and side effects. It does not create a persistent cache across visitors, page loads, or separate Joomla requests.

Once per Page Request

This is QCDR's default and recommended mode. When the PHP Token is actually needed, QCDR runs the PHP, captures its raw output, and stores that success/failure result in a request-local cache keyed to the Token.

If the same Token appears again during that Joomla request, QCDR reuses the captured raw PHP output instead of running the PHP again. The cache ends with the request; the next page request can execute the PHP again.

Nested Tokens Still Resolve at Each Use

When cached PHP output contains another QCDR placeholder, QCDR reuses the raw PHP output but resolves the nested Token again at each occurrence. That allows the nested Token's normal targeting/context rules to be evaluated at the place where the cached PHP result is used without rerunning the PHP itself.

Every Occurrence

Every occurrence bypasses the request-local PHP result cache. A standalone placeholder can therefore run the code separately each time that Token is encountered in eligible rendered output.

When a Rule uses the PHP Token, QCDR first finds and selects real Rule matches. The PHP is then resolved for each selected eligible match rather than being executed speculatively on a page where the Rule has nothing to replace.

Why Repeated Execution Can Be Dangerous

Every occurrence can repeat anything the PHP does—not just its displayed value. A page with five occurrences could potentially perform five database writes, five API calls, five emails, or five increments unless your code prevents that.

Use Every occurrence only when repeated execution is intentional, bounded, and safe. Do not select it simply because the Token appears multiple times; Once per page request already displays the captured result at later occurrences.

When Once per Page Request Is the Better Choice

  • Database/API reads whose result can be reused throughout one page.
  • Code that sends messages, writes data, increments counters, or performs other side effects.
  • Expensive computation or remote calls.
  • Most Tokens whose value should be consistent across the rendered page.

When Every Occurrence May Be Appropriate

Use the advanced mode only when the code is deliberately designed to execute independently for each occurrence and the resulting repeated side effects or cost are acceptable. Test with a page containing multiple occurrences so you verify actual call counts rather than assuming them.

Failure Caching

In Once per page request mode, QCDR also caches the Token's failed result for that request. A hidden PHP failure therefore remains unresolved at later occurrences without repeatedly executing the same failing code. Every occurrence can encounter—and log—the failure repeatedly because it intentionally reruns the PHP.


Community Discussion

Want to compare workflows, share practical tips, or discuss how you use this QCDR feature? Visit the QC Dynamic Replacer Community. For private support, bug reports, account-specific issues, or feature requests, use the QuantaCade support system.