I have pricing that I load from my billing system whmcs to my WordPress website using PHP.
I wanted to know if there is a way I can preload it for it to load nicely or cache only that page or something that will make the page just show without loading slowly.
Thanks
I have pricing that I load from my billing system whmcs to my WordPress website using PHP.
I wanted to know if there is a way I can preload it for it to load nicely or cache only that page or something that will make the page just show without loading slowly.
Thanks
Share Improve this question edited Jun 10, 2019 at 21:16 fuxia♦ 107k39 gold badges255 silver badges459 bronze badges asked Jun 10, 2019 at 21:07 Thovhakale MurendeniThovhakale Murendeni 111 bronze badge 2- How often is the pricing updated in your billing system? – ChristopherJones Commented Jun 10, 2019 at 21:29
- @ChristopherJones Pricing is changed often. It links to the exchange rate. – Thovhakale Murendeni Commented Jun 12, 2019 at 10:50
1 Answer
Reset to default 3WordPress has Transient and Object Cache APIs available. In a default WordPress install, Transients are stored in the database while Object Cache is stored in memory for the duration of the request. You can change this configuration to using something like Redis, Memcache, or APC to store and access this faster.
In your case, you'd want to use Transients.
Here's a good example from the Transient API Codex:
<?php
// Get any existing copy of our transient data
if ( false === ( $special_query_results = get_transient( 'special_query_results' ) ) ) {
// It wasn't there, so regenerate the data and save the transient
$special_query_results = new WP_Query( 'cat=5&order=random&tag=tech&post_meta_key=thumbnail' );
set_transient( 'special_query_results', $special_query_results, 12 * HOUR_IN_SECONDS );
}
// Use the data like you would have normally...
?>