Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2023-03-21 21:31:27

Pemischl
Member
From: Vienna, Austria
Registered: 2012-01-14
Posts: 22
Website

Send-Last-modified sends Thu, 01 Jan 1970 00:00:00 GMT

If I have the Preference “Send “Last-Modified” header?” activated. The Header Response for last-modified is set to “Thu, 01 Jan 1970 00:00:00 GMT”.

I have done a complete clean install of txp 4.8.8, diagnostics are fine, I have evend tried switching the theme but the problem persists on all sites.

https://vic-hikingclub.com

Do you have any idea, what the problem could be?

Offline

#2 2023-03-21 22:10:18

etc
Developer
Registered: 2010-11-11
Posts: 5,210
Website GitHub

Re: Send-Last-modified sends Thu, 01 Jan 1970 00:00:00 GMT

The reason must be here. Our pre-4.8.8 rfc822 format was not the true RFC822 but valid for last-modified header. Now it’s correct but invalid header-wise (should be RFC7231). Most servers are permissive, but probably not yours. To fix, I’m afraid, the only way is to edit txplib_misc.php file, replacing rfc822 in handle_lastmod() function with '%a, %d %b %Y %H:%M:%S GMT'. Sorry for that.

Offline

#3 2023-03-21 23:30:10

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,456
Website GitHub

Re: Send-Last-modified sends Thu, 01 Jan 1970 00:00:00 GMT

etc wrote #335149:

the only way is to edit txplib_misc.php file, replacing rfc822 in handle_lastmod() function with '%a, %d %b %Y %H:%M:%S GMT'.

Can we raise a callback in handle_lastmod() (or safe_strftime()???) so someone whose server is affected can at least plugin their way to a solution?


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Online

#4 2023-03-22 09:00:48

etc
Developer
Registered: 2010-11-11
Posts: 5,210
Website GitHub

Re: Send-Last-modified sends Thu, 01 Jan 1970 00:00:00 GMT

Bloke wrote #335150:

Can we raise a callback in handle_lastmod() (or safe_strftime()???) so someone whose server is affected can at least plugin their way to a solution?

It’s hopefully fixed in 4.9, though someone should test it on a misbehaving server (I’ve got none).

Actually, placing this in the page template might work too (untested):

<txp:php>
        // Make sure lastmod isn't in the future.
        $unix_ts = min(get_lastmod(), time());

        $last = gmdate('D, d M Y H:i:s \G\M\T', $unix_ts);
        header("Last-Modified: $last", true);
</txp:php>

Offline

Board footer

Powered by FluxBB