You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by Apache Wiki <wi...@apache.org> on 2008/02/24 12:22:37 UTC

[Solr Wiki] Update of "SolrAndHTTPCaches" by ThomasPeuss

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Solr Wiki" for change notification.

The following page has been changed by ThomasPeuss:
http://wiki.apache.org/solr/SolrAndHTTPCaches

The comment on the change is:
Updated to reflect what has been committed to Subversion

------------------------------------------------------------------------------
  
  == Configuration ==
  === Solr ===
- You have to add some fields to the ''defaults'' part of your request handler configuration. When they are absent Solr switches off the generation of cache header elements.
- 
- {{{
- <requestHandler ...>
-    <lst name="defaults">
-    
-       ...
- 
-       <int name="httpCacheTTL">0</int>
-       <bool name="httpCacheForceRevalidation">true</bool>
-       <bool name="httpCacheForcePrivate">false</bool>
-    </lst>
- </requestHandler>
- }}}
- 
-  * httpCacheTTL: the cache livetime of a request in seconds before a shared cache either validates the freshness with the backend server or throws the cached request away.
-  * httpCacheForceRevalidation: force the HTTP cache to strictly follow your rules if set to ''true'' or if set to ''false'' allow to serve stale requests to the client (depending of the configuration of the shared cache).
-  * httpCacheForcePrivate: If set to ''true'' indicates that all or part of the response message is intended for a single user and MUST NOT be cached by a shared cache. Private caches (for example in your browser) are still allowed to cache.
- 
- Freshness checking is a light-weight operation for Solr if the index has not changed. So setting ''httpCacheTTL'' to a small value is OK. You can set it to a very high value (24h or more) if your index changes not that often and you can live with outdated responses for the client. The HTTP standard documentation says that you should not exceed 31536000 seconds (which is one year).
- 
  Solr honors following request header elements:
   * If-None-Match
   * If-Match
@@ -35, +14 @@

   * If-Unmodified-Since
  
  Solr emits following response header elements:
-  * Last-Modified: the time the index reader has been opened for the current index.
-  * ETag: the version of the index currently in use.
-  * Expires: Last-Modified+httpCacheTTL
-  * Cache-Control: dependent on your settings for ''httpCacheTTL'', ''httpCacheForceRevalidation'' and ''httpCacheForcePrivate''
+  * Last-Modified
+  * ETag
+  * Expires
+  * Cache-Control
  
  <!> Solr only emits cache header elements for GET and HEAD requests. The HTTP standard does not allow cache related headers for POST requests. POST requests are not cached by standard compliant shared caches!
  
+ All this gets configured in SolrConfigXml.
- ==== Disable caching for certain requests ====
- To disable caching for a certain request you can add the parameter ''httpnocache=true'' to your request. Here is an example
- {{{
-    http://localhost:8080/apache-solr-1.3-dev/select/?q=solr&httpnocache=true
- }}}
- This lets Solr emit header elements to tell shared caches that this request should not be cached.
  
  === Squid Cache ===
  No special configuration is needed for [http://www.squid-cache.org/ Squid Cache]. The only thing you need to check is that the configuration parameter [http://www.squid-cache.org/Versions/v2/2.6/cfgman/cache.html cache] does not contain the \? pattern (this prevents all GET requests with parameters from beeing cached). The ''cache'' parameter tells Squid what never gets cached.