Blipper Widget v1.2.3: now with caching

While working on the Plugin-readme Parser plugin, I noticed that it generated the HTML/XHTML required to render the readme file, then cached it, increasing performance and reducing the number of hits on the WordPress (WP) servers.

This seemed like a good thing to add to Blipper Widget: the generation of the HTML for a blip is quite intensive, and the Blipfoto servers are rate-limited.

Plugin-readme Parser uses WP transients to store the HTML for a given instance of readme file for no longer than a given amount of time. These transients seemed ideal for Blipper Widget.

Therefore, I added caching via transients to Blipper Widget.

When I tested caching locally, all was well. I could see the transients, their keys and their contents after creation, expiry and deletion. It was time to test it on an actual website (while in maintenance mode).

I uninstalled Blipper Widget 1.2.3 and replaced it with the latest version on GitHub. I loaded the front page of this website and checked out the transients.

There were no Blipper Widget transients to be found. That couldn’t be right, could it?

After adding debug messages to the WP error log, which clearly showed me that the transients were being created and saved as I expected, I was puzzled. But a clue was staring me in the face: the transient-viewing plug-in I was using said that not all data might be shown because I was using my old friend object caching.

The W3 Total Cache plugin stores transients in the database, which Transient Manager doesn’t find. I asked ChatGPT how to turn this behaviour off:

To turn off W3 Total Cache’s storing of transients in the database, you can follow these steps:

  1. Log in to your WordPress dashboard and navigate to the W3 Total Cache plugin settings page.
  2. Click on the Database Cache tab.
  3. Under the Object Cache section, uncheck the option “Use the database for page caching”.
  4. Click the Save Settings & Purge Caches button to save your changes and clear any existing caches.

By unchecking the Use the database for page caching option, W3 Total Cache will no longer store transients in the database. Instead, it will use other caching methods, such as caching to the server’s file system or to a CDN.

ChatGPT

I followed these instructions, and the transients reappeared.

This is all well and good for my site, but what if someone else installs Blipper Widget? Will transients work for them or will object caching cause strange behaviour?

Does W3 Total Cache cache transients effectively? When I searched the WP options table in the database (before disabling the use of the database for page caching), I saw neither hide nor hair of any transients, whether created by Blipper Widget or otherwise. Without being able to perform performance tests, I must merely hope that all will be well.

All did seem well, even in WP 6.2,* so I removed the development version of Blipper Widget from this site, and reinstalled version 1.2.2. I pulled the Git repo into the SVN repo’s trunk, using a cunning git-in-svn set-up. I copied the trunk into a new tags directory, 1.2.3, and committed all the changes.

*I have not yet tested importing Blipper Widget, a classic widget, into a block theme.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.