I am facing a puzzling issue with permalinks on a WordPress site that has been running on the same host for several years. A recent upgrade of WordPress, its plugins, or the shared hosting infrastructure might have caused this, but since it is not exactly known when it started, it's difficult to pinpoint the exact cause.
Symptoms: as soon as a new post is published, everything works OK for all the posts. About 15 minutes later, the most recent post (based on date, not ID) will stop working - navigating to its permalink will result in the usual WP 404 page. Editing the post will make it work again - for 15 minutes. Changing permalink settings will make it work - for 15 minutes. It is always the most recent post that gets broken.
What I've tried: besides what's described above, tested multiple browsers, connections, HTTP 1.1 vs. 2.0, tested disabling caching (xcache/opcache) in the hosting control panel, upgraded WordPress from 5.8.x to the latest 6.1.x, to no avail. There are no errors logged to any of the logs when this happens.
Setup: WordPress 6.1.1-sk_SK, theme: Twenty Eleven 4.2 with a custom child theme, a number of plugins, running on PHP 7.4 with MySQL 5.7.
The .htaccess file currently has the mod_rewrite rules for the Really Simple SSL plugin and the generic BEGIN WordPress/END WordPress block plus php_value opcache.enable 0
line.
I'm suspecting it could be somehow linked to the fairly old TwentyEleven theme? Or something completely different? I'm running out of ideas on what to try - any suggestions will be more than welcome!
Update: after testing on a site mirror, it looks like it might be the child theme, which was created for Twenty Eleven 1.7 and last updated for version 2.8, but Twenty Eleven is now at version 4.2. The wait period makes this difficult to test so I'm still not 100% sure but this seems likely.
Update 2: in the end, it was not the child theme, but the Google XML Sitemap plugin at version 4.1.5. Disabling the plugin or upgrading to 4.1.7 fixed the issue - so far, at least. I'll keep watching the site before marking this resolved.