main #1
@@ -40,6 +40,12 @@ func (a *App) handleListPools(w http.ResponseWriter, r *http.Request) {
|
|||||||
if pools == nil {
|
if pools == nil {
|
||||||
pools = []models.Pool{}
|
pools = []models.Pool{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set cache-control headers to prevent caching - pools list changes frequently
|
||||||
|
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
|
||||||
|
w.Header().Set("Pragma", "no-cache")
|
||||||
|
w.Header().Set("Expires", "0")
|
||||||
|
|
||||||
writeJSON(w, http.StatusOK, pools)
|
writeJSON(w, http.StatusOK, pools)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,6 +120,11 @@ func (a *App) handleDeletePool(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set cache-control headers to prevent caching of this response
|
||||||
|
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
|
||||||
|
w.Header().Set("Pragma", "no-cache")
|
||||||
|
w.Header().Set("Expires", "0")
|
||||||
|
|
||||||
writeJSON(w, http.StatusOK, map[string]string{"message": "pool destroyed", "name": name})
|
writeJSON(w, http.StatusOK, map[string]string{"message": "pool destroyed", "name": name})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@@ -230,7 +231,7 @@ func (rw *cacheResponseWriter) Write(b []byte) (int, error) {
|
|||||||
|
|
||||||
// shouldSkipCache determines if a path should skip caching
|
// shouldSkipCache determines if a path should skip caching
|
||||||
func (a *App) shouldSkipCache(path string) bool {
|
func (a *App) shouldSkipCache(path string) bool {
|
||||||
// Skip caching for dynamic endpoints
|
// Skip caching for dynamic endpoints and ZFS/storage endpoints that change frequently
|
||||||
skipPaths := []string{
|
skipPaths := []string{
|
||||||
"/metrics",
|
"/metrics",
|
||||||
"/healthz",
|
"/healthz",
|
||||||
@@ -238,10 +239,20 @@ func (a *App) shouldSkipCache(path string) bool {
|
|||||||
"/api/v1/system/info",
|
"/api/v1/system/info",
|
||||||
"/api/v1/system/logs",
|
"/api/v1/system/logs",
|
||||||
"/api/v1/dashboard",
|
"/api/v1/dashboard",
|
||||||
|
"/api/v1/pools",
|
||||||
|
"/api/v1/pools/available",
|
||||||
|
"/api/v1/datasets",
|
||||||
|
"/api/v1/zvols",
|
||||||
|
"/api/v1/disks",
|
||||||
|
"/api/v1/shares/smb",
|
||||||
|
"/api/v1/exports/nfs",
|
||||||
|
"/api/v1/iscsi/targets",
|
||||||
|
"/api/v1/snapshots",
|
||||||
|
"/api/v1/snapshot-policies",
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, skipPath := range skipPaths {
|
for _, skipPath := range skipPaths {
|
||||||
if path == skipPath {
|
if path == skipPath || strings.HasPrefix(path, skipPath+"/") {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user