rankmath / seo-by-rank-math

Rank Math is a revolutionary WordPress SEO Plugin that combines the features of many SEO tools and lets you multiply your traffic in the easiest way possible :bulb: :chart_with_upwards_trend: →
https://rankmath.com
107 stars 52 forks source link

Fixed #61: Remove caching form sitemap headers #62

Closed marcwiest closed 3 years ago

marcwiest commented 3 years ago

Closes/Fixes #61

isaumya commented 3 years ago

Hey guys any update on this PR? This really needs to be fixed asap.

balazsrm commented 3 years ago

Hi @isaumya This issue will be fixed in the next update for Rank Math. Until then, you can just fix it in your own copy by applying the same changes as in this PR. Hope that helps.

isaumya commented 3 years ago

Hi @balazsmts, That's exactly what I wanted to hear as I've already made the manual changes inside the code even before the PR was pushed. So, if the fix is not added in the upcoming release I have to do it all over again for all of our client sites. :) Thanks. :)

isaumya commented 3 years ago

Hey @balazsmts & @marcwiest, I have been doing some thorough testing and found that when cache-control is removed from the PHP, no matter how hard we try to add a cache-control header using nginx or whatever it doesn't work as the sitemap_index.xml file doesn't actually exists physically and instead generated by PHP.

So, I think instead of simply removing the cache-control header we should add

'Cache-Control' => 'no-cache, no-store, must-revalidate, max-age=0'

Same thing for robots.txt. As when that file is also getting generated dynamically via PHP using robots_txt filter there is no cache-control header and adding a cache-control at the server rules doesn't help as to server the file doesn't exist and it is processed via PHP.