This is a simple Node.js express application that uses the express.static
middleware to serve an HTML page that is autogenerated at build time using an npm build
script.
- Build the app:
pack build bp-mtime-issue \
--builder docker.io/paketobuildpacks/builder-jammy-full:latest \
--creation-time now
- Run the app:
docker run -it -ePORT=8080 -p8080:8080 bp-mtime-issue
-
Load the app in your browser: http://localhost:8080/
-
Repeat steps 1 - 3 and note the content on the page did not change.
-
Hard refresh the page and note the content on the page changes.
Note the Last-Modified
header is set to Tue, 01 Jan 1980 00:00:01 GMT
:
❯ curl -v localhost:8080
* Host localhost:8080 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
* Trying [::1]:8080...
* Connected to localhost (::1) port 8080
> GET / HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/8.5.0
> Accept: */*
>
< HTTP/1.1 200 OK
< X-Powered-By: Express
< Accept-Ranges: bytes
< Cache-Control: public, max-age=0
< Last-Modified: Tue, 01 Jan 1980 00:00:01 GMT
< ETag: W/"3f-49773873e8"
< Content-Type: text/html; charset=UTF-8
< Content-Length: 63
< Date: Thu, 23 May 2024 22:20:15 GMT
< Connection: keep-alive
< Keep-Alive: timeout=5
<
<html><body><h1>Built at: 05/23/24 18:10:12</h1></body></html>
* Connection #0 to host localhost left intact
All the file mtimes have been set set Jan 1 1980:
docker run --entrypoint launcher -it bp-mtime-issue "ls -al"
total 60
drwxrwxrwx 4 1001 cnb 4096 Jan 1 1980 .
drwxr-xr-x 1 root root 4096 May 23 22:25 ..
drwxr-x--- 8 1001 cnb 4096 Jan 1 1980 .git
-rw-r----- 1 1001 cnb 0 Jan 1 1980 README.md
-rw-r----- 1 1001 cnb 282 Jan 1 1980 index.js
lrwxrwxrwx 1 1001 cnb 69 Jan 1 1980 node_modules -> /tmp/4d6b8328f31f0ade280f708051b532cf52e67649547d1c558ce7df2ecb94a806
-rw-r----- 1 1001 cnb 25436 Jan 1 1980 package-lock.json
-rw-r----- 1 1001 cnb 355 Jan 1 1980 package.json
drwxr-x--- 2 1001 cnb 4096 Jan 1 1980 public
-rw-r--r-- 1 1001 cnb 124 Jan 1 1980 start.sh
Even the files that were generated at build time:
docker run --entrypoint launcher -it bp-mtime-issue "ls -al ./public"
total 12
drwxr-x--- 2 1001 cnb 4096 Jan 1 1980 .
drwxrwxrwx 4 1001 cnb 4096 Jan 1 1980 ..
-rw-r----- 1 1001 cnb 63 Jan 1 1980 index.html
The express web server uses file mtimes to the the Last-Modified
header by default (see here),