mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 04:31:10 +08:00
FEATURE: provide extra signal about content age to crawlers
Adds Last-Modified field to help teach crawlers not to crawl old content
This commit is contained in:
@ -117,6 +117,14 @@ class TopicsController < ApplicationController
|
||||
|
||||
canonical_url UrlHelper.absolute_without_cdn(@topic_view.canonical_path)
|
||||
|
||||
# provide hint to crawlers only for now
|
||||
# we would like to give them a bit more signal about age of data
|
||||
if use_crawler_layout?
|
||||
if last_modified = @topic_view.posts&.map { |p| p.updated_at }&.max&.httpdate
|
||||
response.headers['Last-Modified'] = last_modified
|
||||
end
|
||||
end
|
||||
|
||||
perform_show_response
|
||||
|
||||
rescue Discourse::InvalidAccess => ex
|
||||
|
Reference in New Issue
Block a user