HTTP Response Modified Date for Topics

AI-generated summary

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.

Hello!

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?

Thanks.

Still trying to figure this out!

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.

Hi, this is what I mean.

https://meta.discourse.org/t/populating-a-test-database-with-large-number-of-posts-users/38600/3

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:

curl --head https://meta.discourse.org/t/populating-a-test-database-with-large-number-of-posts-users/38600/3
HTTP/1.1 200 OK
Date: Tue, 27 Feb 2018 22:28:19 GMT
Content-Type: text/html
Connection: keep-alive
Server: nginx
Vary: Accept-Encoding
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
X-Discourse-Route: topics/show
Cache-Control: no-store, must-revalidate, no-cache, private
X-Request-Id: b17b8ff0-02db-4d72-8f68-db1deec2e5d9
X-Runtime: 0.025722
Referrer-Policy: no-referrer-when-downgrade
Strict-Transport-Security: max-age=31536000

Is this considered normal behavior?

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.

That is how HTTP caching works.

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.

Thanks for the help.