summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/gitblit/servlet/PagesServlet.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/gitblit/servlet/PagesServlet.java')
-rw-r--r--src/main/java/com/gitblit/servlet/PagesServlet.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/main/java/com/gitblit/servlet/PagesServlet.java b/src/main/java/com/gitblit/servlet/PagesServlet.java
index f578f86f..a8e83418 100644
--- a/src/main/java/com/gitblit/servlet/PagesServlet.java
+++ b/src/main/java/com/gitblit/servlet/PagesServlet.java
@@ -15,10 +15,19 @@
*/
package com.gitblit.servlet;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Date;
+
+import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.revwalk.RevCommit;
+
import com.gitblit.Constants;
+import com.gitblit.utils.JGitUtils;
/**
* Serves the content of a gh-pages branch.
@@ -73,4 +82,22 @@ public class PagesServlet extends RawServlet {
protected void setContentType(HttpServletResponse response, String contentType) {
response.setContentType(contentType);;
}
+
+ @Override
+ protected void streamFromRepo(HttpServletResponse response, Repository repository,
+ RevCommit commit, String requestedPath) throws IOException {
+
+ response.setDateHeader("Last-Modified", JGitUtils.getCommitDate(commit).getTime());
+ response.setHeader("Cache-Control", "public, max-age=3600, must-revalidate");
+
+ super.streamFromRepo(response, repository, commit, requestedPath);
+ }
+
+ @Override
+ protected void sendContent(HttpServletResponse response, Date date, InputStream is) throws ServletException, IOException {
+ response.setDateHeader("Last-Modified", date.getTime());
+ response.setHeader("Cache-Control", "public, max-age=3600, must-revalidate");
+
+ super.sendContent(response, date, is);
+ }
}