From d7508c03e3c476315b8bda5f67065d9de521fa02 Mon Sep 17 00:00:00 2001 From: Laptop Date: Tue, 8 Oct 2024 22:01:05 +0300 Subject: [PATCH] increase cache time for hls.js; add some more stuff to readme --- README.md | 42 ++++++++++++++++++++++++++++++++++++++++++ main.go | 2 +- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a22d721..14dcf5f 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,7 @@ go get ``` 7. *Optional.* Edit config: + You can change some values in `lib/cfg/init.go` if you want. Keep in mind that you need to rebuild the binary each time you want to update the config. 8. Build binary: @@ -84,6 +85,47 @@ go build main.go This will run soundcloak on localhost, port 4664. (by default) +# Maintenance-related stuffs +## Updating +1. Retrieve the latest code: + +```sh +git fetch origin +git pull +``` + +2. Remove compressed versions of files: +The webserver is configured to locally cache compressed versions of files. They have `.fiber.gz` extension and can be found in `assets` folder and `node_modules/hls.js/dist`. If any static files have been changed, you should purge these files so the new versions can be served. Static files are also cached in user's browser, so you will need to clean your cache to get the new files (Ctrl + F5) + +For example, you can clean these files from `assets` folder like so: +```sh +cd assets +rm *.fiber.gz +``` + +3. *Optional.* Edit config: + +Sometimes, new updates add new config values. You can change some values in `lib/cfg/init.go` if you want. + + +4. Regenerate templates (if they changed): + +```sh +templ generate +``` + +5. Build binary: +```sh +go build main.go +``` + +6. Run it: +```sh +./main +``` + +Congratulations! You have succesfully updated your soundcloak. (hopefully this guide works) + # Built with ## Backend - [Go programming language](https://github.com/golang/go) diff --git a/main.go b/main.go index 66364b4..11caee2 100644 --- a/main.go +++ b/main.go @@ -34,7 +34,7 @@ func main() { } app.Static("/", "assets", fiber.Static{Compress: true, MaxAge: 3600}) - app.Static("/js/hls.js/", "node_modules/hls.js/dist", fiber.Static{Compress: true, MaxAge: 3600}) + app.Static("/js/hls.js/", "node_modules/hls.js/dist", fiber.Static{Compress: true, MaxAge: 14400}) app.Get("/search", func(c *fiber.Ctx) error { q := c.Query("q")