Skip to content

Commit 178603c

Browse files
authored
Merge pull request #325 from ampproject/master
Cherry-pick onto v2
2 parents 581d266 + 66736f2 commit 178603c

File tree

4 files changed

+13
-44
lines changed

4 files changed

+13
-44
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -29,41 +29,4 @@ Guidelines](https://opensource.google.com/conduct/).
2929

3030
# Getting Started
3131

32-
## Cloning the repository
33-
34-
When cloning, use `git clone -b master`; the default branch is `releases` which
35-
is not meant for developing against.
36-
37-
## Running a development server
38-
39-
Copy `amppkg.example.toml` to `amppkg.toml` and modify it to suit your needs.
40-
You may use `testdata/b1/server.{cert,privkey}` to get started. However, you are
41-
at your own risk if you instruct your browser to trust `server.cert`. *NEVER*
42-
instruct your browser to trust `ca.cert`.
43-
44-
## Presubmits
45-
46-
- Run `go fmt` on the code you change. Don't run `go fmt ./...`; this affects
47-
files that are mirrored from Google to GitHub, so we can't change them here.
48-
- Make sure `go test ./...` passes.
49-
- `golint` and `go vet` are optional.
50-
- Make sure PRs are sent to `master` and not `releases`, unless you're releasing
51-
a new version of amppkg.
52-
53-
## New dependencies
54-
55-
Feel free to add dependencies on small code if it implements a feature that's
56-
hard to implement yourself. Try not to add large dependencies, or dependencies
57-
for the sake of minor development inconvenience (unless it's for test code
58-
only). They add risk by bringing in code of unknown provenance, and bloat the
59-
binary.
60-
61-
If you need to add or upgrade dependencies, AMP Packager uses
62-
[dep](https://golang.github.io/dep/).
63-
64-
# Suggestions for contributions
65-
66-
Take a look at [good first
67-
issues](https://github.com/ampproject/amppackager/labels/good%20first%20issue),
68-
and please communicate early and often, to ensure we agree on the solution
69-
before you invest a lot of time into its implementation.
32+
See the [Contributing wiki](../../wiki/Contributing).

packager/certcache/certcache.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ func (this *CertCache) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
169169
expiry = 0
170170
}
171171
resp.Header().Set("Cache-Control", "public, max-age="+strconv.Itoa(expiry))
172-
resp.Header().Set("ETag", "\""+this.certName+"\"")
173172
resp.Header().Set("X-Content-Type-Options", "nosniff")
174173
cbor, err := this.createCertChainCBOR(ocsp)
175174
if err != nil {

packager/signer/signer.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -504,10 +504,17 @@ func (this *Signer) serveSignedExchange(resp http.ResponseWriter, fetchResp *htt
504504
resp.Header().Set("AMP-Cache-Transform", act)
505505
}
506506

507-
// TODO(twifkak): Add Cache-Control: public with expiry to match when we think the AMP Cache
508-
// should fetch an update (half-way between signature date & expires).
509507
resp.Header().Set("Content-Type", accept.SxgContentType)
510-
resp.Header().Set("Cache-Control", "no-transform")
508+
// We set a zero freshness lifetime on the SXG, so that naive caching
509+
// intermediaries won't inhibit the update of this resource on AMP
510+
// caches. AMP caches are recommended to base their update strategies
511+
// on a combination of inner and outer resource lifetime.
512+
//
513+
// If you change this code to set a Cache-Control based on the inner
514+
// resource, you need to ensure that its max-age is no longer than the
515+
// lifetime of the signature (6 days, per above). Maybe an even tighter
516+
// bound than that, based on data about client clock skew.
517+
resp.Header().Set("Cache-Control", "no-transform, max-age=0")
511518
resp.Header().Set("X-Content-Type-Options", "nosniff")
512519
if _, err := resp.Write(body.Bytes()); err != nil {
513520
log.Println("Error writing response:", err)

packager/signer/validation_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ import (
1313

1414
func urlFrom(url *url.URL, err *util.HTTPError) *url.URL { return url }
1515

16-
func errorFrom(url *url.URL, err *util.HTTPError) *util.HTTPError { return err }
17-
1816
func urlOrDie(spec string) *url.URL {
1917
url, err := url.Parse(spec)
2018
if err != nil {
@@ -24,6 +22,8 @@ func urlOrDie(spec string) *url.URL {
2422
}
2523

2624
func TestParseURL(t *testing.T) {
25+
errorFrom := func(url *url.URL, err *util.HTTPError) *util.HTTPError { return err }
26+
2727
assert.EqualError(t, errorFrom(parseURL("", "sign")), "sign URL is unspecified")
2828
if err := errorFrom(parseURL("abc-@#79!%^/", "sign")); assert.NotNil(t, err) {
2929
assert.Contains(t, err.Error(), "Error parsing sign URL")

0 commit comments

Comments
 (0)