You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by jp...@apache.org on 2012/08/28 05:33:15 UTC

git commit: TS-1249: Disable ESI packed nodes by default

Updated Branches:
  refs/heads/master 4ebd0a4b3 -> 224693119


TS-1249: Disable ESI packed nodes by default

The ESI plugin has an internal mechanism that can try to cache a
more efficient version (called packed node in the code) of the ESI
response instead of the raw text. The hope, I think, is to make
parsing much easier for subsequent requests. The mechanism works
like this:
  a) Determine that the ESI response has the proper cache control
     header and is cacheable
  b) Issue a internal "POST" request to the same URL with the same
     requests headers. The post data is the packed node
     version of the ESI response
  c) Intercept this internal request and replace the existing cache
     with it.

I find this mechanism extremely hard to get to work. So I turn if
off completely. It is also later on found to be a incorrect mechanism,
too, in yahoo!. The mechanism does not take into account that key
for HTTP cache can be changed with the Vary header in the response.


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/22469311
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/22469311
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/22469311

Branch: refs/heads/master
Commit: 224693119ac435ad961dcbd1bc03e0f5b529fccb
Parents: 4ebd0a4
Author: Shu Kit Chan <ch...@gmail.com>
Authored: Mon Aug 27 20:27:53 2012 -0700
Committer: James Peach <jp...@apache.org>
Committed: Mon Aug 27 20:27:59 2012 -0700

----------------------------------------------------------------------
 plugins/experimental/esi/Makefile.am        |    3 +-
 plugins/experimental/esi/lib/gzip.cc        |    2 +-
 plugins/experimental/esi/plugin.cc          |   26 ++++++++++++++++++++++
 plugins/experimental/esi/serverIntercept.cc |    2 +
 4 files changed, 31 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/22469311/plugins/experimental/esi/Makefile.am
----------------------------------------------------------------------
diff --git a/plugins/experimental/esi/Makefile.am b/plugins/experimental/esi/Makefile.am
index 210bee5..0e7123c 100644
--- a/plugins/experimental/esi/Makefile.am
+++ b/plugins/experimental/esi/Makefile.am
@@ -21,7 +21,8 @@ AM_CXXFLAGS = \
   -I$(srcdir)/fetcher \
   -I$(srcdir)/test \
   -I$(top_builddir)/proxy/api \
-  -I$(top_srcdir)/proxy/api
+  -I$(top_srcdir)/proxy/api \
+  -Wno-deprecated
 
 pkglib_LTLIBRARIES = esi.la
 lib_LTLIBRARIES = libesi.la

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/22469311/plugins/experimental/esi/lib/gzip.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/esi/lib/gzip.cc b/plugins/experimental/esi/lib/gzip.cc
index 0ec0ee4..f938151 100644
--- a/plugins/experimental/esi/lib/gzip.cc
+++ b/plugins/experimental/esi/lib/gzip.cc
@@ -192,7 +192,7 @@ EsiLib::gunzip(const char *data, int data_len, BufferList &buf_list) {
     return false;
   }
   int32_t orig_size;
-  uLong orig_crc;
+  uint32_t orig_crc;
   extract(data + data_len, orig_crc);
   extract(data + data_len + 4, orig_size);
   if ((crc != orig_crc) || (unzipped_data_size != orig_size)) {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/22469311/plugins/experimental/esi/plugin.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/esi/plugin.cc b/plugins/experimental/esi/plugin.cc
index f217a73..a0a2ded 100644
--- a/plugins/experimental/esi/plugin.cc
+++ b/plugins/experimental/esi/plugin.cc
@@ -20,10 +20,13 @@
   See the License for the specific language governing permissions and
   limitations under the License.
  */
+#define __STDC_FORMAT_MACROS
+#define __STDC_LIMIT_MACROS
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <inttypes.h>
+#include <stdint.h>
 #include <limits.h>
 #include <string.h>
 #include <string>
@@ -418,6 +421,7 @@ ContData::~ContData()
   }
 }
 
+#ifdef ESI_PACKED_NODE_SUPPORT
 static void
 cacheNodeList(ContData *cont_data) {
   if (TSHttpTxnAborted(cont_data->txnp) == TS_SUCCESS) {
@@ -453,6 +457,7 @@ cacheNodeList(ContData *cont_data) {
   TSFetchUrl(post_request.data(), post_request.size(), cont_data->client_addr,
                   cont_data->contp, NO_CALLBACK, event_ids);
 }
+#endif
 
 static int
 transformData(TSCont contp)
@@ -568,7 +573,9 @@ transformData(TSCont contp)
       }
       if (cont_data->esi_proc->completeParse()) {
         if (cont_data->os_response_cacheable) {
+#ifdef ESI_PACKED_NODE_SUPPORT
           cacheNodeList(cont_data);
+#endif
         }
       }
     }
@@ -828,8 +835,12 @@ modifyResponseHeader(TSCont contp, TSEvent event, void *edata) {
           destroy_header = true;
         } else if (Utils::areEqual(name, name_len, TS_MIME_FIELD_AGE, TS_MIME_LEN_AGE)) {
           destroy_header = true;
+#ifdef ESI_PACKED_NODE_SUPPORT
         } else if (!mod_data->cache_txn &&
                    Utils::areEqual(name, name_len, MIME_FIELD_XESI, MIME_FIELD_XESI_LEN)) {
+#else
+        } else if (Utils::areEqual(name, name_len, MIME_FIELD_XESI, MIME_FIELD_XESI_LEN)) {
+#endif
           destroy_header = true;
         } else if ((name_len > HEADER_MASK_PREFIX_SIZE) &&
                    (strncmp(name, HEADER_MASK_PREFIX, HEADER_MASK_PREFIX_SIZE) == 0)) {
@@ -842,13 +853,17 @@ modifyResponseHeader(TSCont contp, TSEvent event, void *edata) {
               TSDebug(DEBUG_TAG, "[%s] Error while getting value #%d of header [%.*s]",
                        __FUNCTION__, j, name_len, name);
             } else {
+#ifdef ESI_PACKED_NODE_SUPPORT
               if (mod_data->cache_txn) { 
+#endif
                 bool response_cacheable, is_cache_header;
                 is_cache_header = checkForCacheHeader(name, name_len, value, value_len, response_cacheable);
                 if (is_cache_header && response_cacheable) {
                   destroy_header = true;
                 }
+#ifdef ESI_PACKED_NODE_SUPPORT
               } 
+#endif
             } // if got valid value for header
           } // end for
         }
@@ -867,10 +882,13 @@ modifyResponseHeader(TSCont contp, TSEvent event, void *edata) {
       addMimeHeaderField(bufp, hdr_loc, TS_MIME_FIELD_CONTENT_ENCODING, TS_MIME_LEN_CONTENT_ENCODING,
                          TS_HTTP_VALUE_GZIP, TS_HTTP_LEN_GZIP);
     }
+
+#ifdef ESI_PACKED_NODE_SUPPORT
     if (mod_data->cache_txn) {
       addMimeHeaderField(bufp, hdr_loc, TS_MIME_FIELD_VARY, TS_MIME_LEN_VARY, TS_MIME_FIELD_ACCEPT_ENCODING,
                          TS_MIME_LEN_ACCEPT_ENCODING);
     }
+#endif
     TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
     TSDebug(DEBUG_TAG, "[%s] Inspected client-bound headers", __FUNCTION__);
     retval = 1;
@@ -923,6 +941,7 @@ checkHeaderValue(TSMBuffer bufp, TSMLoc hdr_loc, const char *name, int name_len,
   return retval;
 }
 
+#ifdef ESI_PACKED_NODE_SUPPORT
 static void
 maskOsCacheHeaders(TSHttpTxn txnp) {
   TSMBuffer bufp;
@@ -981,6 +1000,7 @@ maskOsCacheHeaders(TSHttpTxn txnp) {
   } // end header iteration
   TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
 }
+#endif
 
 static bool
 isTxnTransformable(TSHttpTxn txnp, bool is_cache_txn) {
@@ -1156,7 +1176,11 @@ addTransform(TSHttpTxn txnp, bool processing_os_response) {
   }
 
   TSHttpTxnTransformedRespCache(txnp, 0);
+#ifdef ESI_PACKED_NODE_SUPPORT
   TSHttpTxnUntransformedRespCache(txnp, 0);
+#else
+  TSHttpTxnUntransformedRespCache(txnp, 1);
+#endif
 
   TSDebug(DEBUG_TAG, "[%s] Added transformation (0x%p)", __FUNCTION__, contp);
   return true;
@@ -1216,7 +1240,9 @@ globalHookHandler(TSCont contp, TSEvent event, void *edata) {
           // we'll 'mask' OS cache headers so that traffic server will
           // not try to cache this. We cannot outright delete them
           // because we need them in our POST request; hence the 'masking'
+#ifdef ESI_PACKED_NODE_SUPPORT
           maskOsCacheHeaders(txnp);
+#endif
         }
       } else {
         TSDebug(DEBUG_TAG, "[%s] handling cache lookup complete event...", __FUNCTION__);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/22469311/plugins/experimental/esi/serverIntercept.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/esi/serverIntercept.cc b/plugins/experimental/esi/serverIntercept.cc
index 068f6a2..06c3458 100644
--- a/plugins/experimental/esi/serverIntercept.cc
+++ b/plugins/experimental/esi/serverIntercept.cc
@@ -21,6 +21,8 @@
   limitations under the License.
  */
 
+#define __STDC_FORMAT_MACROS
+
 #include "serverIntercept.h"
 
 #include <string>