Skip to content

Commit

Permalink
Only cache HTTP 200 OK responses.
Browse files Browse the repository at this point in the history
  • Loading branch information
Homme Zwaagstra committed Mar 20, 2015
1 parent fbf9935 commit 6009423
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions handlers/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ func (this *Cache) ServeHTTP(w http.ResponseWriter, r *http.Request) {
tee := MultiWriter(w, recorder)
this.handler.ServeHTTP(tee, r)

// Only cache 200 responses.
if rec.Code != 200 {
return
}

// If the cache limit has been exceeded, don't proceed to cache the
// response.
if limiter != nil && limiter.LimitExceeded() {
Expand Down

0 comments on commit 6009423

Please sign in to comment.