The topic discusses the issue of the Last Modified date in Discourse topic pages always corresponding to the current time, rather than the actual date of the last update. Magnetidog noticed this behavior and inquired about altering the Last Modified date.
Mittineague clarified that this might be a bug if the time always indicates the current time. However, schleifer explained that the content on each page is updated every time it’s loaded, making the Last Modified header irrelevant.
Magnetidog provided an example of the issue using curl to check the Last Modified header of an old thread. schleifer further explained that the Last Modified header is not part of the Discourse API and is used in conjunction with the Cache-Control header to recommend dynamic content caching to web browsers.
Magnetidog plans to work around this issue by adding a “published” meta tag, allowing external search platforms/plugins to extract the last update date from Discourse.
I have a question. I noticed that when checking the “modified date” of a topic on Discourse, the modified date always corresponds to the date in which the page is being browsed.
Is there some way to alter the Last Modified date, at least in topic pages?
I am unclear about what you mean by “corresponds to”.
If you mean that the time always indicates “current time”, that sounds like a bug.
If you mean what I would call “in relation to current time” eg. 4 days ago, instead of February 23 2018 I think a plugin should be able to use the timestamp to show the actual date instead of the time interval.
If I check the Last-Modified header for this old thread from 2016, the Lqst Modified date corresponds to the moment I browsed the website, not to the moment it was last updated:
The content on that page is updated every time it’s loaded. For example, look at the Suggested Topics section.
A Last-Modified header is not part of the discourse API. It’s a recommendation to the web browser (to be used in conjunction with the Cache-Control header) that the page being requested is dynamic content and should not be cached.
Thanks, I am familiar with HTTP caching and the way headers are used.
The issue started for me when working with existing search platforms/plugins acting as web spiders (so indexing the pages from the outside, without direct access to the discourse DB), which seem incapable of extracting the last update date from Discourse and rely instead on the Last Modified date.
I think I might work around this by adding a “published” meta tag and forcing the plugins to use that date.