papachumba
Forum Replies Created
-
Hiya, no 410 redirect, only a 410 header issued and the function exits. This executes before WP initializes so currently the browser throws up its own internal error message indicating no content, due to the header. (Setting 410 status “content gone” and then still showing the said content surely is NOT content that is gone :). How likely is google to ignore said content even though it has a “theoretically incorrect” header indicating that it is not there. 🙂
Upon reading what Matt Cutts had to say on this, https://searchenginewatch.com/sew/how-to/2340728/matt-cutts-on-how-google-handles-404-410-status-codes
I think I may be right:
“So when you do serve a 410 status code on a page that really isn’t gone permanently, you haven’t killed that page off permanently. Googlebot will return the check and see if the page needs to be returned to the index.”FYI regarding 404s returning instead of 410 – I have observed similar comments on plugin feedback where other users are reporting the same for the Purge Fix. Similar what seemed to have been happening with some of my attachment URLs. With above function, all urls are handled without fail.
Additionally, considering we are dealing with content that is not there any more, should a webmaster really publish a sitemap listing said content (even though it has status 410).
Perhaps it would be wiser to remove the attachment sitemap from sitemaps, let google use its own index for these attachment urls, when it hits it sees a 410 for each URL, and providing no content it excludes it from the index. (maybe it retries a few times), and finally settles with only valid urls in the sitemap against its index.Well, I have just added a function with a hash lookup in functions.php which goes through the list of attachment urls, issues a 410, and then exists (meaning NO content apart from the “status gone” header is sent to browser)
Here’s the code if anyone else needs it for functions.php (I have manually added all URLs to the code to make it quicker, by copying from the attachment sitemap):
function my_custom_410_handler() {
$currenturl = ‘https://’.$_SERVER[‘HTTP_HOST’] . $_SERVER[‘REQUEST_URI’];
$badurls = [
“attachment_url1” => true,
“attachment_url2” => true,
“attachment_url3” => true,
];
if (isset($badurls[strtolower($currenturl)])) {
header( “HTTP/1.1 410 Gone” );
exit;
}
}
add_action(‘parse_request’, ‘my_custom_410_handler’);Additionally, I noticed certain URLs from attachment sitemap generated by the fix are not returning the correct 410 status code. Instead, they are resolving to a normal 404 page.
Example:
https://bit.ly/2vrIAmF- This reply was modified 7 years, 9 months ago by papachumba.
- This reply was modified 7 years, 9 months ago by papachumba.
I thought of your solution too, WP Cache comes with a URL filter module.
However entering 2500 Friendly URLS of attachment images into a filter of any kind, even .htaccess directly, is bound to exponentially slow down the server.
In this case, I could just paste the links from the generated attachment sitemap into a 410 redirection function in functions.php and circumvent the Yoast Purge plugin, avoiding the problem altogether (maybe).I am thinking more along the lines of locating the source of incorrect content header being set, and solving the problem that way. Is this a problem which can be replicated with anyone running these two plugins together or could it be specific to my server setup?
WP Cache & Purge Plugins ON – binary response with 410 status
WP Cache cleared & both plugins ON – binary response with 410 status
WP Cache OFF with Purge Plugin ON – image response with correct content type with 410 status
WP Cache ON with Purge Plugin OFF – image response with correct content type without 410 statusHowever, it is not viable for us to turn off the caching plugin due to speed benefits.
Is there any solution targeting this so both WP Cache and Purge plugins are ON however binary response is eliminated and correct content header is set when rendering images?Yes, the header shows 410 status.
Hiya, you are correct. As soon as I disabled WP Super cache response was a normal image, with 410 status.
So I guess the issue lies somewhere between these two plugins.
I noticed Content-Type header of the response was set to text/html so something somewhere thinks it is outputting text rather than an image (could be due to page->image redirect in yoast settings?)Tried clearing the cache, however when both Caching & Yoast Purge plugins are On response goes back to binary.
- This reply was modified 7 years, 9 months ago by papachumba.