Why does file server not refresh?

I am creating a website and I have a static folder served with file server. Problem is when I change something in the static folder it does not update. Even after restarting with go run <file path>.go.
Here is my code:

package main

import (
	"log"
	"net/http"
        /*internal imports*/
)

const Connection = "<temporary way of setting the sql connection string, not related to this problem>"

func main() {
	http.HandleFunc("/", server.MainServe) /*server is included in internal imports*/
        /*here are more handle function definitions*/
	http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("<root of a project>/web/static"))))
	/*second file server, same definition and the same problem.*/
	log.Fatal(http.ListenAndServe(":8080", nil))
}

1 Like

What do you mean with “does not update”?

Have you remembered to disable/purge the browsers cache?

1 Like

I mean that files keep their old content. For example I modify css and a browsers sees it how it was before.

You are right. I did not disable browsers cache. Sorry for posting this here.

Welcome to supporting web apps, where 60% of all issues just turn out to be aggressive browser caching. The other 40% are people who lie and say they’re using the latest version of Chrome but are actually using Internet explorer. :wink:

3 Likes

I use brave. Private mode has fixed my issue.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.