Closed as duplicate of#60940
Closed as duplicate of#60940
Description
Go version
go version go1.24.3 linux/amd64
Output of go env
in your module/workspace:
AR='ar'
CC='cc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='c++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/var/home/anon/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/var/home/anon/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build3141057410=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/dev/null'
GOMODCACHE='/var/home/anon/.local/share/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/var/home/anon/.local/share/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/var/home/linuxbrew/.linuxbrew/Cellar/go/1.24.3/libexec'
GOSUMDB='sum.golang.org'
GOTELEMETRY='off'
GOTELEMETRYDIR='/var/home/anon/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/var/home/linuxbrew/.linuxbrew/Cellar/go/1.24.3/libexec/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.24.3'
GOWORK=''
PKG_CONFIG='pkg-config'
What did you do?
This is just #42051. Re-reported because I think it was incorrectly closed.
The program is still:
package main
import (
"flag"
"fmt"
"log"
"net/http"
"os"
"strconv"
)
func main() {
port := flag.Int("p", 8000, "port number")
dir := flag.String("d", ".", "directory path")
flag.Parse()
fi, err := os.Stat(*dir)
if err != nil {
log.Fatal(err)
}
if !fi.IsDir() {
log.Fatal(fmt.Errorf("%s isn't a directory\n", *dir))
}
addr := ":" + strconv.Itoa(*port)
handler := http.FileServer(http.Dir(*dir))
fmt.Printf("serving %s on http://localhost:%d\n", *dir, *port)
log.Fatal(http.ListenAndServe(addr, handler))
}
- Run the program in directory A.
- Navigate to
localhost:8000
in Chrome or Firefox. - A directory listing for directory A is shown.
- Now terminate the program and reopen it in directory B
- Refresh the page in Chrome or Firefox.
- The directory listing for directory A is still shown.
I believe this has something to do with the interaction between the Last-Modified response and If-Modified-Since request headers.
I have tested this on Firefox and Chrome on both Linux and macOS.
What did you see happen?
The content of the directory where the server was previously running and status code 304
What did you expect to see?
The current directory listing