Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cache control header and fix storing of etag closes #3076 #3079

Merged
merged 1 commit into from
Sep 1, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/github.com/getlantern/flashlight/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,9 @@ func (cfg Config) fetchCloudConfig() ([]byte, error) {
req.Header.Set(ifNoneMatch, lastCloudConfigETag[url])
}

// Prevents intermediate nodes (CloudFlare) from caching the content
req.Header.Set("Cache-Control", "no-cache")

// make sure to close the connection after reading the Body
// this prevents the occasional EOFs errors we're seeing with
// successive requests
Expand All @@ -374,11 +377,11 @@ func (cfg Config) fetchCloudConfig() ([]byte, error) {
return nil, fmt.Errorf("Unexpected response status: %d", resp.StatusCode)
}

lastCloudConfigETag[url] = resp.Header.Get(etag)
gzReader, err := gzip.NewReader(resp.Body)
if err != nil {
return nil, fmt.Errorf("Unable to open gzip reader: %s", err)
}
lastCloudConfigETag[url] = resp.Header.Get(etag)
log.Debugf("Fetched cloud config")
return ioutil.ReadAll(gzReader)
}
Expand Down