Solving the Facebook Post Sharing Issue with Comet Cache and Super Page Cache
If you're using caching plugins like Comet Cache or Super Page Cache alongside CleanTalk Security FireWall or CleanTalk Anti-Spam's Anti-Crawler, Anti-Flood, and SpamFireWall features, you might have encountered a problem: your caching plugins could be saving blocking pages intended for bots. This can result in real users accidentally seeing these cached blocking pages when trying to share posts on Facebook.
What's the core of the problem?
When CleanTalk identifies a bot, it generates a blocking page with an HTTP 403 Forbidden response. This status code indicates that the server received the request but refuses to fulfill it because access to the requested resource is forbidden. CleanTalk blocking pages also include special tags that explicitly prohibit their caching. This is designed to ensure that regular website visitors never see these pages.
However, despite these precautions, Comet Cache and Super Page Cache have a peculiarity: they can cache even pages with a 403 response. As a result, if a bot visited a page and was blocked, that blocking page might get cached. The next time a real visitor tries to access the same page, they might be shown that exact cached blocking page instead of the expected content.
Solving the Facebook Post Sharing Issue with Comet Cache
To fix this, you need to exclude the URLs Facebook uses to collect metadata from Comet Cache's caching. Typically, Facebook sends requests with specific User-Agents.
Add an exclusion for the Facebook Bot User-Agent in Comet Cache:
- Navigate to the Comet Cache plugin settings in your WordPress admin dashboard: Plugins → Comet Cache
- Find the User-Agent Exclusion section.
- Add the following User-Agents that Facebook uses to the User-Agent exclusion list: facebot, facebookexternalhit.
- Save your changes.
- After adding the exclusion, ensure that you completely clear all cached data within Comet Cache.
Solving the Facebook Post Sharing Issue with Super Page Cache
- Add the following code in the function.php file of your active theme:
For Anti-Spam:
add_action('apbct_firewall_before_die', function ($_result) { if ( ! headers_sent() ) { $cookie_name = 'apbct_firewall_die'; $cookie_value = '1'; $cookie_expiration = time() + 3600; // 1 hour $cookie_path = '/'; setcookie($cookie_name, $cookie_value, $cookie_expiration, $cookie_path); } });
For Security
add_action('spbct_firewall_before_die', function ($_result) { if ( ! headers_sent() ) { $cookie_name = 'spbc_firewall_die'; $cookie_value = '1'; $cookie_expiration = time() + 3600; // 1 hour $cookie_path = '/'; setcookie($cookie_name, $cookie_value, $cookie_expiration, $cookie_path); } });
- Navigate to the Super Page Cache settings in your WordPress admin dashboard: Plugins → Super Page Cache
- Add the following cookies to the Super Page Cache exclusion list:
For Anti-Spam: apbct_firewall_die
For Security: spbc_firewall_die - Update settings.
- After adding the exclusion, ensure that you completely clear all cached data within Super Page Cache.
This might be helpful
- How to Set Up the Anti-Spam by CleanTalk and WP Rocket
- How to Set Up the Anti-Spam by CleanTalk and W3 Total Cache
- Fixing False Positives in the CleanTalk Anti-Spam while using cache plugins
- Specifics of the CleanTalk Anti-Spam Protection and Cache Plugins on WordPress
Need help?
- Visit our Help Center.
- Or email us directly at support@cleantalk.org — we’re always here to help.
Thanks for being with us!