主站点地图中,下级站点地图的 lastmod 日期不正确:
例如,请参见 https://meta.discourse.org/sitemap.xml
sitemap_2.xml 到 sitemap_5.xml 的日期均为 ‘2024-03-14T14:02:32Z’ - 这正是“3 天前”。
<sitemapindex>
<sitemap>
<loc>https://meta.discourse.org/sitemap_recent.xml</loc>
<lastmod>2024-03-17T14:02:29Z</lastmod>
</sitemap>
<sitemap>
<loc>https://meta.discourse.org/sitemap_1.xml</loc>
<lastmod>2024-03-17T14:02:29Z</lastmod>
</sitemap>
<sitemap>
<loc>https://meta.discourse.org/sitemap_2.xml</loc>
<lastmod>2024-03-14T14:02:32Z</lastmod>
</sitemap>
<sitemap>
<loc>https://meta.discourse.org/sitemap_3.xml</loc>
<lastmod>2024-03-14T14:02:32Z</lastmod>
</sitemap>
<sitemap>
<loc>https://meta.discourse.org/sitemap_4.xml</loc>
<lastmod>2024-03-14T14:02:32Z</lastmod>
</sitemap>
<sitemap>
<loc>https://meta.discourse.org/sitemap_5.xml</loc>
<lastmod>2024-03-14T14:02:32Z</lastmod>
</sitemap>
</sitemapindex>
技术问题:
不知何故,sitemap_[2-5].xml 使用了 3.days.ago,因为 sitemap.last_posted_topic 可能未返回有效值。
另一点:在 last_posted_topic 中也使用 bumped_at
与主题站点地图 sitemap_[1-5].xml 本身的 lastmod 进行比较:
未经测试的伪代码:
def last_posted_topic
[sitemap_topics.maximum(:bumped_at), sitemap_topics.maximum(:updated_at)].max
end