Disable caching for revision URLs using "current"

The current revision is resolved dynamically and may change. Do
not allow browser level caching on these URLs as the contents can
(and usually does) change in the future.

Clients that want caching must request the revision-id using a stable
identifier, ideally the commit SHA-1, or at least the unique patch
set number. This allows contents to cache as data behind the URL
will not change.

Change-Id: I00c5c607a78297dadaf5d5338f025aaf4832af63
This commit is contained in:
Shawn Pearce
2013-07-12 10:21:41 -07:00
parent 18f26bd6b7
commit c2cb3cda1d
6 changed files with 33 additions and 7 deletions

View File

@@ -29,12 +29,17 @@ public class RevisionResource implements RestResource {
private final ChangeResource change;
private final PatchSet ps;
private boolean cacheable = true;
public RevisionResource(ChangeResource change, PatchSet ps) {
this.change = change;
this.ps = ps;
}
public boolean isCacheable() {
return cacheable;
}
public ChangeResource getChangeResource() {
return change;
}
@@ -58,4 +63,9 @@ public class RevisionResource implements RestResource {
IdentifiedUser getUser() {
return (IdentifiedUser) getControl().getCurrentUser();
}
RevisionResource doNotCache() {
cacheable = false;
return this;
}
}