Why may my answer server be serving old static files?

Viewed 185

I am new to golang embed, but I am trying to use the answer platform to set-up a customized forum for an open source platform for my company.

I modified the code in the ui directory which is reflected in the respective build directory (./ui/build). However upon requesting the server, it serves old chunks not currently present in ./ui/build.

My assumption is that the files are being cached somewhere in the go pipeline, but even after several go clean ./... into go generate ./... and go build ./... it seems to still pull the old file paths (and somehow the files).

If it helps, I am on Windows 11 and running the server locally (not in docker atm).

1 Answers

After modifying the ui code, you must compile it before building the binary.

$ make ui
$ make build

If you don't have the make command, you can try executing the corresponding command directly.

Of course, I'd also like to know exactly what part of the ui code you changed. Whether it was due to the change itself.

There is also the case of how you are looking at the ui to see if it has changed, if it's in the form of looking at the source code, you may not see the change because the view is of the SEO page. If it's selecting elements maybe you can see the changes.

A note about go embed. As long as there are changes in the ui build folder. There will always be changes after running go build.

Thanks for looking into this. Turns out go build ./... doesn't do anything. Thank you for recommending a second look at the build file.

I am having the same issue, and this solution does not seem to work.

After having changed the ui code, for example the i18n/en_US.yaml file, I run:

$ make ui
$ make build

Then, I start the server again using:

go run cmd/answer/main.go run -C ./answer-data

But when browsing to localhost, I still see strings in i18n/en_US.yaml prior to my changes. Did I miss something?

You can try to use go run cmd/answer/main.go upgrade -C ./answer-data before run it.