Incompatibility between Cachify and Head Cleaner

I’ve been trying out some of the CP plugins in the directory, and I just want to share this problem that I had.

For my caching plugin, I’m using Cachify from WordPress (https://wordpress.org/plugins/cachify/). It is simple and easy to use, and in my server environment, it offers two caching method: database and hard disk.

Now, I’ve tried the Head Cleaner plugin (https://directory.classicpress.net/plugins/head-cleaner), and much as I’d love to use it, it clashes with Cachify. At first, pages will load normally, with the unneeded tags in the header stripped out, but the second time they are loaded (that is, when the cached pages are supposed to be displayed), only white blank pages are shown.

Uninstalling Head Cleaner brings the situation back to normal.

Now, I’ve tried both database caching and hard disk caching, and the problem persists. As far as I can tell, Cachify works fine. I’ve even monitored the cached files in the hard disk using SFTP, and they are either created or flushed according to what I’m doing.

Note: This isn’t me asking for support. Head Cleaner is working as intended in ClassicPress. I’m just sharing this in case others have the same issue using it with another WordPress caching plugin.

3 Likes

I’ve tried using a similar head cleaner plugin from the WP repo (https://wordpress.org/plugins/wp-head-cleaner/), and the behavior was the same. Blank white pages when loading the cached files.

Note: I examined the cached HTMLs, and the unnecessary tags were indeed stripped from the header. The problem is only in loading these files.

Then I tried adding this to my wp-config.php file:

define( ‘WP_CACHE’, true );

I don’t know if Cachify is supposed to add this to the config file, but as per the recommendation of my webhost, I have restrictive file permissions, and my wp-config.php is unwritable by CP. Usually, when a plugin needs write permission on files and directories, it informs me, and I make the changes manually. But Cachify didn’t inform me of any needed change in the config file, only in .htaccess.

Now, with WP_CACHE set to true:

Using Head Cleaner for ClassicPress, the cached files are still not loaded. Blank pages still.

But using wp_head() cleaner for WordPress, the cached files are now finally loaded.

2 Likes

Thank you for reporting this and for trying other plugins.
I’ll look at the issue shortly.

Simone.

2 Likes

Seems the problem is when Remove the pingback tag is enabled.
I’ve a fix but first I want to check with the original author of Head Cleaner, so tagging @Code_Potent.

Changing the priority of the action here from -1 to 999 seems to solve the problem.
Are there reasons not to do so?

add_action('template_redirect', [$this, 'pingback_buffer_start'], -1);
2 Likes

In all honesty, I can’t recall why I used -1 for the priority – perhaps it was for edge cases – however, I can say with certainty that there was a reason because I don’t use negative numbers for priorities, as a general rule, and when I set them, the values are very intentional.

I don’t immediately see any issue with decreasing the priority here with a higher value, but, I’d say, “test it very thoroughly to be sure a fix for one user isn’t a break for everyone else.


Sidenote: for any devs happening along and saying “oh, you can use negative values for priorities?!” – know that, while negative priorities are allowed, they are best left for special cases.

1 Like

Just a heads up that the latest version for Head Cleaner is noted as 1.1.0 at the directory page, however, the download link is pointing at 1.2.0.

Seems that the directory updates automatically to point to the latest release file but the version is not updated. Pinging @wadestriebel :wink:

2 Likes

@Simone @Code_Potent I am certainly an edge case. This plugin is not critical for me (and like I said, I’ve found a WP plugin alternative), and so don’t make the changes in the code if you don’t have to.

How much of an edge case am I? You tell me, because I can only compare my webhost to other webhosts based on my readings.

I’m hosting my websites in NearlyFreeSpeech.Net. It’s a DIY, security-focused, FreeBSD-based, pay-as-you-go webhost for experienced webmasters. I’m still a novice webmaster, and a Windows user besides, with little experience in Linux, and so I’m struggling, but I have my reasons for choosing NFSN.

In NFSN, website administration is done mostly through SSH and SFTP. The custom control panel has no direct access to the files. File and directory permissions are also very restrictive, and they disapprove of any CMS updating itself over the web. That is, there are no web updates, not for core, themes, or plugins. (They said that they have security precautions that prevent this.) Everything has to be installed or updated using a tool like WP-CLI or done manually.

The only reason I’m able to make a start on using WordPress (and by extension, ClassicPress) is that they have a detailed tutorial on how to install and configure it, down to the exact commands to use in the command line.

1 Like

@arjayarana version 1.2.1-rc1 should solve the problem you pointed out.
Let me know if it works for you.
I’ll test this fix before pushing an official update.

@Code_Potent thank you!

3 Likes

Thanks!

1 Like

@Simone EVERYTHING WORKS FINE! THANK YOU!

I’ve tested it with both database and hard disk caching: OK

I’ve tested it with or without define( 'WP_CACHE', true ); in wp-config.php: OK

And so it seems setting WP_CACHE to true in wp-config.php is not needed after all.

2 Likes

Here are the settings I’ve used, by the way:

4 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.