ChangeScreen2: Allow browser caching of /detail

When sending /detail responses to the browser allow the data to
be cached locally at the browser. Use HTTP standard Last-Modified
and If-Modified-Since HTTP response and request headers to manage
cache invalidation when the change has been updated.

This permits the server to skip out early and avoid formatting JSON
for the change if nothing has happened to the change since the last
view since by this user. This can save hundreds of milliseconds in
response time when revisting a recently viewed change.

Change-Id: Ifab60d58a454adccfb75c542fd64df147c463c1f
This commit is contained in:
Shawn Pearce
2013-07-18 12:42:27 -07:00
parent dd30152179
commit 5b568d326d
6 changed files with 107 additions and 16 deletions

View File

@@ -15,12 +15,15 @@
package com.google.gerrit.server.change;
import com.google.gerrit.extensions.restapi.RestResource;
import com.google.gerrit.extensions.restapi.RestResource.HasLastModified;
import com.google.gerrit.extensions.restapi.RestView;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.server.project.ChangeControl;
import com.google.inject.TypeLiteral;
public class ChangeResource implements RestResource {
import java.sql.Timestamp;
public class ChangeResource implements RestResource, HasLastModified {
public static final TypeLiteral<RestView<ChangeResource>> CHANGE_KIND =
new TypeLiteral<RestView<ChangeResource>>() {};
@@ -41,4 +44,9 @@ public class ChangeResource implements RestResource {
public Change getChange() {
return getControl().getChange();
}
@Override
public Timestamp getLastModified() {
return getChange().getLastUpdatedOn();
}
}