HTTP Response Modified Date for Topics


(Magnetidog) #1

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.


(Magnetidog) #2

Still trying to figure this out!


(Mittineague) #3

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.


(Magnetidog) #4

Hi, this is what I mean.

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?


(Andrew Schleifer) #5

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.


(Magnetidog) #6

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.