Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(2)

Issue 3500042: Support for ETags in JsServlet

Can't Edit
Can't Publish+Mail
Start Review
Created:
15 years, 4 months ago by jtarrio
Modified:
15 years, 4 months ago
Reviewers:
johnfargo, shindig.remailer
Base URL:
http://svn.apache.org/repos/asf/shindig/trunk/
Visibility:
Public.

Description

Adds a class to generate and cache ETags, and uses it in JsServlet. Later, we can extend this to other servlets :)

Patch Set 1 #

Total comments: 1

Patch Set 2 : Optionally invalidate ETags when container configuration changes #

Messages

Total messages: 3
jtarrio
15 years, 4 months ago (2010-12-07 23:33:48 UTC) #1
jtarrio
Optionally invalidate ETags when container configuration changes
15 years, 4 months ago (2010-12-09 01:28:30 UTC) #2
johnfargo
15 years, 4 months ago (2010-12-09 01:47:47 UTC) #3
http://codereview.appspot.com/3500042/diff/1/java/gadgets/src/main/java/org/a...
File
java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/EtagHandler.java
(right):

http://codereview.appspot.com/3500042/diff/1/java/gadgets/src/main/java/org/a...
java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/EtagHandler.java:54:
return request.equals(cache.get(etag));
IMO we don't need a tag cache - we only need a consistent mechanism for hashing
output. The cache risks storing a large amount of data, and as well a given
JsUri (or other request key) could yield different results (ie. if JS is
updated).

I'd prefer to see validation logic move to the output stage. For simplicity,
phase #1 can still be JsServlet-only, but the technique is really dead-simple.
All our output is batched anyway, so the additional cost of computing a hash
from JsResponse (or ProxyResponse, etc in future CLs) is fairly small.

To make this generic, I was thinking something like:
1. Introduce ETagHttpOutput class.
  - one method: void emitOutput(HttpServletRequest, HttpServletResponse,
ETaggable);

2. Let ETaggable be an interface exposing InputStream getContent() and String
getETag(). If getETag() is null, compute it as hash(getContent()). This allows
pre-caching of ETag computation, such as in the Proxy server.

You could do away w/ the getETag()/interface idea as well, at least at first.
WDYT?
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b