Closed

Description
What version of Go are you using (go version
)?
$ go version go version go1.15.2 linux/amd64
Does this issue reproduce with the latest release?
No sure.
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go env GO111MODULE="on" GOARCH="amd64" GOBIN="" GOCACHE="/home/cubte/.cache/go-build" GOENV="/home/cubte/.config/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GOMODCACHE="/home/cubte/.local/go/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/home/cubte/.local/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/usr/local/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64" GCCGO="gccgo" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="/dev/null" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build051727565=/tmp/go-build -gno-record-gcc-switches"
What did you do?
I have this program,
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))
}
I compiled and ran it on my home directory. I went to web browser and visited localhost:8000. I then stopped the program and ran it inside a directory of home directory. when i refresh the browser window i don't see that directory's content. I still see the previous directory. The server is still sending 304
. It requires to disable cache to see the content of the directory where the server is currently running.
What did you expect to see?
The server will send the content where it is currently running.
What did you see instead?
It is sending content of the directory where the server was previously running and status code 304