I run the code
package main
import (
"fmt"
"net/http"
)
func main() {
http.HandleFunc("/", sroot)
http.ListenAndServe(":8080", nil)
}
func sroot(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Welcome")
}
and browser showed a response as expected: Welcome
then, after some time I try to change the output but have found that the output does not change! so, when I change the output fmt.Fprintf(w, "Welcome 123")
but browser still ouptuts Welcome
.
So what's the magic happens here?
You can use gin
to reload your webserver.
Installation: go get github.com/codegangsta/gin
Usage: gin run filename.go
Reference: https://github.com/codegangsta/gin
By default the browser makes a GET
request when navigating to the page. The browser is also going to make some decisions about the 'cachability' of the page: Has the url changed? Has the querystring changed? Has the ETAG changed? If none of these are true, the browser is most likely serving a cached version of the page.