Skip to content

Commit

Permalink
Merge pull request #71 from deggja/bugfix_70
Browse files Browse the repository at this point in the history
feat: added headers to fix caching issue, fixes #70 #minor
  • Loading branch information
deggja committed Dec 13, 2023
2 parents 20c21bd + 07877ea commit 78b76d9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions backend/cmd/dash.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ func init() {
rootCmd.AddCommand(dashCmd)
}

func setNoCacheHeaders(w http.ResponseWriter) {
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
w.Header().Set("Pragma", "no-cache")
w.Header().Set("Expires", "0")
}

func startDashboardServer() {
// Verify connection to cluster or throw error
clientset, err := k8s.GetClientset()
Expand Down Expand Up @@ -89,6 +95,9 @@ func startDashboardServer() {
// }

func dashboardHandler(w http.ResponseWriter, r *http.Request) {
// Set cache control headers
setNoCacheHeaders(w)

statikFS, err := fs.New()
if err != nil {
log.Fatal(err)
Expand All @@ -111,6 +120,7 @@ func handleNamespacesWithPoliciesRequest(w http.ResponseWriter, r *http.Request)
return
}

setNoCacheHeaders(w)
w.Header().Set("Content-Type", "application/json")
if err := json.NewEncoder(w).Encode(struct {
Namespaces []string `json:"namespaces"`
Expand All @@ -133,6 +143,7 @@ func handleClusterVisualizationRequest(w http.ResponseWriter, r *http.Request) {
return
}

setNoCacheHeaders(w)
w.Header().Set("Content-Type", "application/json")
if err := json.NewEncoder(w).Encode(clusterVizData); err != nil {
http.Error(w, "Failed to encode cluster visualization data", http.StatusInternalServerError)
Expand Down
Binary file modified backend/netfetch
Binary file not shown.
2 changes: 1 addition & 1 deletion backend/statik/statik.go

Large diffs are not rendered by default.

0 comments on commit 78b76d9

Please sign in to comment.