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:
@@ -35,7 +35,10 @@ public class GetCommit implements RestReadView<RevisionResource> {
|
||||
@Override
|
||||
public Response<CommitInfo> apply(RevisionResource resource)
|
||||
throws OrmException, PatchSetInfoNotAvailableException {
|
||||
return Response.ok(json.toCommit(resource.getPatchSet()))
|
||||
.caching(CacheControl.PRIVATE(7, TimeUnit.DAYS));
|
||||
Response<CommitInfo> r = Response.ok(json.toCommit(resource.getPatchSet()));
|
||||
if (resource.isCacheable()) {
|
||||
r.caching(CacheControl.PRIVATE(7, TimeUnit.DAYS));
|
||||
}
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user