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

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

Keeping Objects in Memory

This is a perfect use case for Transients. In WordPress, transients are short-lived data objects. By default, they’re persisted to the database using WordPress’ built-in WP_Object_Cache object. However, you can use a variety of caching plugins (Batcache is an outstanding one that works with Memcached) to store Transients in memory. To set a transient, call … Read more

Cannot add version of main.css to wordpress on testing enviroment

To answer the question why you can’t add the theme’s version to your CSS file, it’s likely because the Version property of $theme is private so you cannot access it directly, but you can access it through the public get function. Try this instead: $theme = wp_get_theme(); define(‘THEME_VERSION’, $theme->get(‘Version’)); You also don’t need to add … Read more

Multiple WordPress sites eat up a lot of RAM

It’s hard to answer this given that each site is most likely different and each server is also configured differently. If these sites are individual WordPress installs then 1GB /30 sites is normal, an absolute bare minimum per site would be 32MB for apc.shm_size, this equals 960MB with no overhead. 32MB is in my opinion … Read more

WP 3.5 caching problem

Sorry for this but I found out in the end that my ISP was doing some kind of caching on their end. Had to phone them and explain the issue. When they started seeing it too, I kwen the problem was with them. Thanks for all the comments btw.