Javascript behaving unexpectedly on FreeBSD

I have a small snippet of javascript that I add to my webpages
Code:
<center><script language="JavaScript" type="text/javascript">
if (Date.parse(document.lastModified) > 0) {
document.write ('<b>last modified: <\/b>' + document.lastModified +'<p>');
}
document.write('<b> url:<\/b>' + document.location.href + '<\/font><p>');
</script>

If I put the web page on a Linux host, it does what I expect, shows the last update for the page.
However, on a FreeBSD host, rather than show the latest update, it shows the last visit to the page.

I don't know javascript at all, I got this snippet years ago somewhere or other. At the time I had web pages on Linux and it did what I wanted. Is anyone who knows javascript inclined to tell me what should be different on a FreeBSD host? On FreeBSD, it's in a jail, but I don't see how that would be relevant. This happens whether I use Nginx or Apache, and worked on Linux with either web server.
 
fyi, <center>, <font> and "language" in <script> have been marked obsolete for a decade or more. <script> defaults to javascript so you can leave "type" off altogether. But none of that will fix your problem.

The operating system has nothing to do with javascript which runs in the browser alone except in certain modern cases that don't involve this.

After staring at this a while, I think document.lastModified might be the source of the issue. Last modified since when? Does Linux handle the time the same as FreeBSD?
 
@drhowardfine, I don't know. And thanks for the other comments.

sko I'm not sure. I created it during installation, and then created the jail a couple of days ago. I'll have to check and get back to you on that one.
(have to check how to check that, which will be a good learning experience for me, as it's something I feel I should know already).
 
And, this is odd. Suddenly it is behaving correctly, at least on a few random pages I looked at. srobb.net still has last date looked at (that's at a datacenter, also on a FreeBSD jail). The www.scottro.net was on Linux until a few days ago, (RHEL-10.0) and was showing the correct date. But right now, the current www.scottro.net is also showing the correct date. I'm going to wait a bit before marking it solved though.
 
If I put the web page on a Linux host, it does what I expect, shows the last update for the page.
However, on a FreeBSD host, rather than show the latest update, it shows the last visit to the page.
Could it be something like atime/relatime Linux not updating file access timestamps?
 
I only have the one system, which was moved from Linux to FreeBSD yesterday or the day before. Running
Code:
 curl -I https://www.scottro.net/mutt.html
(to choose a random page) gave me

Code:
 last-modified: Tue, 27 Jan

(snipped the rest of it, that just shows me it's working correctly right now, I probably made some change to that page last month.)
Like I said, it seems to be working correctly at the moment, though I do want to test with apache as well.

NOTE: I just tested with apache and when running apache24 curl -I doesn't give a last modified, and when I view the page, it gives the last modified date as today. So it has something to do with apache and nginx. When I ran it on Linux, I was using nginx, so it may be an apache/nginx issue rather than Linux/FreeBSD. But running the same curl -I with apache as the server gets me
curl -I https://www.scottro.net/mutt.html HTTP/1.1 302 Found Date: Thu, 19 Feb 2026 23:00:21 GMT Server: Apache/2.4.66 (FreeBSD) OpenSSL/3.5.4 Location: http://srobb.net/mutt.html Content-Type: text/html; charset=iso-8859-1
And I'm not sure where it's getting the location of srobb, which is on a different server at a company, rather than under my desk like scottro.net
(and it's saying http for srobb, rather than https)

Sorry to be showing my ignorance here. I just created the site years ago, and got it running but, as you can see, know little about web hosting.
 
Back
Top