Skip to content

Commit 394f19f

Browse files
committed
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: golang/go#31944 (comment) 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 <[email protected]> Reviewed-by: Andrew Bonventre <[email protected]>
1 parent a712dec commit 394f19f

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Alternatively, to avoid Cloud Build and build locally:
5656

5757
```bash
5858
make docker
59-
docker tag playground:latest gcr.io/golang-org/playground:latest
59+
docker tag golang/playground:latest gcr.io/golang-org/playground:latest
6060
docker push gcr.io/golang-org/playground:latest
6161
gcloud --project=golang-org [email protected] app deploy app.yaml --image-url=gcr.io/golang-org/playground:latest
6262
```

Diff for: sandbox.go

+5
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ type response struct {
7474
// The handler returned supports Cross-Origin Resource Sharing (CORS) from any domain.
7575
func (s *server) commandHandler(cachePrefix string, cmdFunc func(*request) (*response, error)) http.HandlerFunc {
7676
return func(w http.ResponseWriter, r *http.Request) {
77+
cachePrefix := cachePrefix // so we can modify it below
7778
w.Header().Set("Access-Control-Allow-Origin", "*")
7879
if r.Method == "OPTIONS" {
7980
// This is likely a pre-flight CORS request.
@@ -92,6 +93,10 @@ func (s *server) commandHandler(cachePrefix string, cmdFunc func(*request) (*res
9293
return
9394
}
9495

96+
if req.WithVet {
97+
cachePrefix += "_vet" // "prog" -> "prog_vet"
98+
}
99+
95100
resp := &response{}
96101
key := cacheKey(cachePrefix, req.Body)
97102
if err := s.cache.Get(key, resp); err != nil {

0 commit comments

Comments
 (0)