SOLR-506 -- Emitting HTTP Cache headers can be enabled or disabled through configuration on a per-handler basis

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@683121 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shalin Shekhar Mangar 2008-08-06 06:00:49 +00:00
parent 8d7282df1d
commit 98ff4a03b9
7 changed files with 19 additions and 9 deletions

View File

@ -343,6 +343,9 @@ New Features
68. SOLR-554: Hierarchical JDK log level selector for SOLR Admin replaces logging.jsp (Sean Timm via shalin) 68. SOLR-554: Hierarchical JDK log level selector for SOLR Admin replaces logging.jsp (Sean Timm via shalin)
69. SOLR-506: Emitting HTTP Cache headers can be enabled or disabled through configuration
on a per-handler basis (shalin)
Changes in runtime behavior Changes in runtime behavior
1. SOLR-559: use Lucene updateDocument, deleteDocuments methods. This 1. SOLR-559: use Lucene updateDocument, deleteDocuments methods. This
removes the maxBufferedDeletes parameter added by SOLR-310 as Lucene removes the maxBufferedDeletes parameter added by SOLR-310 as Lucene

View File

@ -82,7 +82,6 @@ public class MoreLikeThisHandler extends RequestHandlerBase
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception
{ {
RequestHandlerUtils.addExperimentalFormatWarning( rsp ); RequestHandlerUtils.addExperimentalFormatWarning( rsp );
rsp.setHttpCaching(true);
SolrParams params = req.getParams(); SolrParams params = req.getParams();
SolrIndexSearcher searcher = req.getSearcher(); SolrIndexSearcher searcher = req.getSearcher();

View File

@ -50,6 +50,7 @@ public abstract class RequestHandlerBase implements SolrRequestHandler, SolrInfo
protected SolrParams invariants; protected SolrParams invariants;
volatile long totalTime = 0; volatile long totalTime = 0;
long handlerStart = System.currentTimeMillis(); long handlerStart = System.currentTimeMillis();
protected boolean httpCaching = true;
/** shorten the class references for utilities */ /** shorten the class references for utilities */
private static class U extends SolrPluginUtils { private static class U extends SolrPluginUtils {
@ -113,6 +114,11 @@ public abstract class RequestHandlerBase implements SolrRequestHandler, SolrInfo
invariants = SolrParams.toSolrParams((NamedList)o); invariants = SolrParams.toSolrParams((NamedList)o);
} }
} }
if (initArgs != null) {
Object caching = initArgs.get("httpCaching");
httpCaching = caching != null ? Boolean.parseBoolean(caching.toString()) : true;
}
} }
public NamedList getInitArgs() { public NamedList getInitArgs() {
@ -125,6 +131,7 @@ public abstract class RequestHandlerBase implements SolrRequestHandler, SolrInfo
numRequests++; numRequests++;
try { try {
U.setDefaults(req,defaults,appends,invariants); U.setDefaults(req,defaults,appends,invariants);
rsp.setHttpCaching(httpCaching);
handleRequestBody( req, rsp ); handleRequestBody( req, rsp );
// count timeouts // count timeouts
boolean timedOut = (Boolean)rsp.getResponseHeader().get("partialResults") == null ? false : (Boolean)rsp.getResponseHeader().get("partialResults"); boolean timedOut = (Boolean)rsp.getResponseHeader().get("partialResults") == null ? false : (Boolean)rsp.getResponseHeader().get("partialResults");

View File

@ -263,7 +263,6 @@ public class SpellCheckerRequestHandler extends RequestHandlerBase implements So
@Override @Override
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp)
throws Exception { throws Exception {
rsp.setHttpCaching(true);
SolrParams p = req.getParams(); SolrParams p = req.getParams();
String words = p.get("q"); String words = p.get("q");
String cmd = p.get("cmd"); String cmd = p.get("cmd");

View File

@ -140,8 +140,6 @@ public class SearchHandler extends RequestHandlerBase implements SolrCoreAware
final RTimer timer = rb.isDebug() ? new RTimer() : null; final RTimer timer = rb.isDebug() ? new RTimer() : null;
rsp.setHttpCaching(true);
if (timer == null) { if (timer == null) {
// non-debugging prepare phase // non-debugging prepare phase
for( SearchComponent c : components ) { for( SearchComponent c : components ) {

View File

@ -75,7 +75,7 @@ public class SolrQueryResponse {
/** /**
* Should this response be tagged with HTTP caching headers? * Should this response be tagged with HTTP caching headers?
*/ */
protected boolean httpCaching=false; protected boolean httpCaching=true;
/*** /***
// another way of returning an error // another way of returning an error

View File

@ -229,7 +229,9 @@
The "standard" request handler is the default and will be used if qt The "standard" request handler is the default and will be used if qt
is not specified in the request. is not specified in the request.
--> -->
<requestHandler name="standard" class="solr.StandardRequestHandler"/> <requestHandler name="standard" class="solr.StandardRequestHandler">
<bool name="httpCaching">true</bool>
</requestHandler>
<requestHandler name="dismaxOldStyleDefaults" <requestHandler name="dismaxOldStyleDefaults"
class="solr.DisMaxRequestHandler" > class="solr.DisMaxRequestHandler" >
<!-- for historic reasons, DisMaxRequestHandler will use all of <!-- for historic reasons, DisMaxRequestHandler will use all of
@ -302,7 +304,9 @@
</requestHandler> </requestHandler>
<requestHandler name="/update" class="solr.XmlUpdateRequestHandler" /> <requestHandler name="/update" class="solr.XmlUpdateRequestHandler" />
<requestHandler name="/update/csv" class="solr.CSVRequestHandler" startup="lazy" /> <requestHandler name="/update/csv" class="solr.CSVRequestHandler" startup="lazy">
<bool name="httpCaching">false</bool>
</requestHandler>
<!-- test elevation --> <!-- test elevation -->
<searchComponent name="elevate" class="org.apache.solr.handler.component.QueryElevationComponent" > <searchComponent name="elevate" class="org.apache.solr.handler.component.QueryElevationComponent" >