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:
@@ -35,6 +35,7 @@ public class CacheControl {
|
||||
private final Type type;
|
||||
private final long age;
|
||||
private final TimeUnit unit;
|
||||
private boolean mustRevalidate;
|
||||
|
||||
private CacheControl(Type type, long age, TimeUnit unit) {
|
||||
this.type = type;
|
||||
@@ -53,4 +54,13 @@ public class CacheControl {
|
||||
public TimeUnit getUnit() {
|
||||
return unit;
|
||||
}
|
||||
|
||||
public boolean isMustRevalidate() {
|
||||
return mustRevalidate;
|
||||
}
|
||||
|
||||
public CacheControl setMustRevalidate() {
|
||||
mustRevalidate = true;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
|
||||
package com.google.gerrit.extensions.restapi;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
* Generic resource handle defining arguments to views.
|
||||
* <p>
|
||||
@@ -21,4 +23,9 @@ package com.google.gerrit.extensions.restapi;
|
||||
* {@link RestView} such as {@link RestReadView} or {@link RestModifyView}.
|
||||
*/
|
||||
public interface RestResource {
|
||||
|
||||
/** A resource with a last modification date. */
|
||||
public interface HasLastModified {
|
||||
public Timestamp getLastModified();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user