fix: disable browser caching on dev proxy responses
CSS/JS changes were not reflected through the proxy because the browser/ WebView cached them. Set Cache-Control: no-cache, no-store, must-revalidate and strip ETag/Last-Modified on all dev proxy responses. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
6a84e5ffd6
commit
a5ccc1166a
1 changed files with 5 additions and 0 deletions
|
|
@ -280,6 +280,11 @@ func (h *Handler) ActivateDevTarget(id string) error {
|
|||
|
||||
proxy := httputil.NewSingleHostReverseProxy(u)
|
||||
proxy.ModifyResponse = func(resp *http.Response) error {
|
||||
// Prevent browser/WebView from caching dev proxy responses (CSS, JS, etc.)
|
||||
resp.Header.Set("Cache-Control", "no-cache, no-store, must-revalidate")
|
||||
resp.Header.Del("ETag")
|
||||
resp.Header.Del("Last-Modified")
|
||||
|
||||
ct := resp.Header.Get("Content-Type")
|
||||
if !strings.Contains(ct, "text/html") {
|
||||
return nil
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue