playground: differentiate cache key based on client JS version Don't share a cache namespace between clients wanting vet (new) and not wanting vet (old). This was causing issues like: https://github.com/golang/go/issues/31944#issuecomment-493094932 And unrelated: a README deploy fix, broken from my earlier Makefile cleanup. Change-Id: Ibed7f91c739ac65e33ee8d73eed066a7a81f938c Reviewed-on: https://go-review.googlesource.com/c/playground/+/177617 Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com> Reviewed-by: Andrew Bonventre <andybons@golang.org>
diff --git a/README.md b/README.md index 6b8d71c..fe6ac19 100644 --- a/README.md +++ b/README.md
@@ -56,7 +56,7 @@ ```bash make docker -docker tag playground:latest gcr.io/golang-org/playground:latest +docker tag golang/playground:latest gcr.io/golang-org/playground:latest docker push gcr.io/golang-org/playground:latest gcloud --project=golang-org --account=you@google.com app deploy app.yaml --image-url=gcr.io/golang-org/playground:latest ```
diff --git a/sandbox.go b/sandbox.go index 2050832..f43eb07 100644 --- a/sandbox.go +++ b/sandbox.go
@@ -74,6 +74,7 @@ // The handler returned supports Cross-Origin Resource Sharing (CORS) from any domain. func (s *server) commandHandler(cachePrefix string, cmdFunc func(*request) (*response, error)) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { + cachePrefix := cachePrefix // so we can modify it below w.Header().Set("Access-Control-Allow-Origin", "*") if r.Method == "OPTIONS" { // This is likely a pre-flight CORS request. @@ -92,6 +93,10 @@ return } + if req.WithVet { + cachePrefix += "_vet" // "prog" -> "prog_vet" + } + resp := &response{} key := cacheKey(cachePrefix, req.Body) if err := s.cache.Get(key, resp); err != nil {