scouting: Let browsers cache the field pictures
These pictures are 100 KiB or so. We shouldn't need to fetch them
every time.
Signed-off-by: Philipp Schrader <philipp.schrader@gmail.com>
Change-Id: If449397db81c7902529fd2a7121533fccd2a6150
diff --git a/scouting/webserver/static/static.go b/scouting/webserver/static/static.go
index 57824d9..92d8086 100644
--- a/scouting/webserver/static/static.go
+++ b/scouting/webserver/static/static.go
@@ -32,8 +32,11 @@
return http.HandlerFunc(fn)
}
-// Serve pages given a port, directory to serve from, and an channel to pass the errors back to the caller.
+// Serve pages in the specified directory.
func ServePages(scoutingServer server.ScoutingServer, directory string) {
// Serve the / endpoint given a folder of pages.
scoutingServer.Handle("/", NoCache(http.FileServer(http.Dir(directory))))
+ // Make an exception for pictures. We don't want the pictures to be
+ // pulled every time the page is refreshed.
+ scoutingServer.Handle("/pictures/", http.FileServer(http.Dir(directory)))
}