Cache responses for /files for 7 days
Like /diff the output for /files is stable given the URL. Allow browsers to cache the file list for 7 days, allowing fast reference back to recently viewed changes. Change-Id: I4fa40c16f1a8e0cb1da5079c5c7641165540d7ff
This commit is contained in:
@@ -16,9 +16,11 @@ package com.google.gerrit.server.change;
|
||||
|
||||
import com.google.gerrit.extensions.registration.DynamicMap;
|
||||
import com.google.gerrit.extensions.restapi.AuthException;
|
||||
import com.google.gerrit.extensions.restapi.CacheControl;
|
||||
import com.google.gerrit.extensions.restapi.ChildCollection;
|
||||
import com.google.gerrit.extensions.restapi.IdString;
|
||||
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
||||
import com.google.gerrit.extensions.restapi.Response;
|
||||
import com.google.gerrit.extensions.restapi.RestReadView;
|
||||
import com.google.gerrit.extensions.restapi.RestView;
|
||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
@@ -29,6 +31,8 @@ import com.google.inject.Provider;
|
||||
|
||||
import org.kohsuke.args4j.Option;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
class Files implements ChildCollection<RevisionResource, FileResource> {
|
||||
private final DynamicMap<RestView<FileResource>> views;
|
||||
private final FileInfoJson fileInfoJson;
|
||||
@@ -73,8 +77,11 @@ class Files implements ChildCollection<RevisionResource, FileResource> {
|
||||
resource.getChangeResource(), IdString.fromDecoded(base));
|
||||
basePatchSet = baseResource.getPatchSet();
|
||||
}
|
||||
return fileInfoJson.toFileInfoMap(
|
||||
resource.getChange(), resource.getPatchSet(), basePatchSet);
|
||||
return Response.ok(fileInfoJson.toFileInfoMap(
|
||||
resource.getChange(),
|
||||
resource.getPatchSet(),
|
||||
basePatchSet))
|
||||
.caching(CacheControl.PRIVATE(7, TimeUnit.DAYS));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user