You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficserver.apache.org by GitBox <gi...@apache.org> on 2021/08/30 05:00:15 UTC

[GitHub] [trafficserver] david187 opened a new issue #8291: ESI include does not process during getting 304 header

david187 opened a new issue #8291:
URL: https://github.com/apache/trafficserver/issues/8291


   version: ats 9.1.0
   
   When ATS receipt "304 Not Modified" header from backend, ESI does not execute and both of the <esi:include> and "x-esi: 1" header will be responsed to client.
   
   P.S. http client does not send IF-NONE-MATCH header, just ATS cache revalidate
   
   ==========
   
   The problem seem caused by content-type header checking:
   
   https://github.com/apache/trafficserver/blob/e44ca802404ed99899d43163fc65e1811ba791af/plugins/esi/esi.cc#L1308
   
   I have tried to add contype-type header in php, but it seem droped by nginx (may be ?)
   
   Here is my lua content-type patch for ESI + 304:
   
   ================
   esi_patch.lua
   
   function do_global_read_response()
      ts.debug('do_global_read_response')
   
      local ct = ts.server_response.header['Content-Type']
   
      local cct = ''
   
       local cache_status = ts.http.get_cache_lookup_status()
       if cache_status == TS_LUA_CACHE_LOOKUP_HIT_FRESH then
           ts.debug('hit')
   
           cct = ts.cached_response.header['Content-Type']
       elseif cache_status == TS_LUA_CACHE_LOOKUP_HIT_STALE then
           ts.debug('hit, stale')
   
           cct = ts.cached_response.header['Content-Type']
       else
           ts.debug('not hit')
       end
   
       
   
       local code = ts.server_response.get_status()
       local xesi = ts.server_response.header['X-ESI']
   
       ts.debug('code:'..code)
       ts.debug(cct)
       ts.debug(xesi)
   
       if xesi ~= nil and ct == nil and code == 304 and cct ~= nil then
                ts.debug('use cct')
                ts.server_response.header['Content-Type'] = cct
                ts.server_response.header['X-Lua-Esi-Patch'] = 1
       end
   
      return 0
   end
   
   
   
   =======
   esi_etag.php
   
   <?php
   header('X-Esi: 1');
   $output = ob_get_contents();
   
   ob_end_clean();
   ?>
   <html>
   <body>
   Hello, <esi:include src="/esi/date.php"/>
   </body>
   </html>
   <?php
   
   $etag = '"'.md5($output).'"';
   
   $if_none_match = isset($_SERVER['HTTP_IF_NONE_MATCH']) ?
           $_SERVER['HTTP_IF_NONE_MATCH'] :
           false ;
   
   if($if_none_match == $etag ){
      header("HTTP/1.1 304 Not Modified");
      exit;
   }
   
   header('cache-control: public, max-age=10');
   header('etag: '.$etag);
   
   echo $output;


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficserver] david187 commented on issue #8291: ESI include does not process during getting 304 header

Posted by GitBox <gi...@apache.org>.
david187 commented on issue #8291:
URL: https://github.com/apache/trafficserver/issues/8291#issuecomment-908383653






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficserver] david187 commented on issue #8291: ESI include does not process during getting 304 header

Posted by GitBox <gi...@apache.org>.
david187 commented on issue #8291:
URL: https://github.com/apache/trafficserver/issues/8291#issuecomment-908391502


   Yes, It work fine for me.
   Please review for the logic is correct or not. 
   Thanks.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficserver] shukitchan commented on issue #8291: ESI include does not process during getting 304 header

Posted by GitBox <gi...@apache.org>.
shukitchan commented on issue #8291:
URL: https://github.com/apache/trafficserver/issues/8291#issuecomment-908375204






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficserver] shukitchan commented on issue #8291: ESI include does not process during getting 304 header

Posted by GitBox <gi...@apache.org>.
shukitchan commented on issue #8291:
URL: https://github.com/apache/trafficserver/issues/8291#issuecomment-998544848


   After rereading this thread, I know I misunderstand something. Now I understand that you are trying to trigger ESI processing on the cached response while ATS is receiving the 304 response from origin. 
   
   This does look like a problem that I can provide a fix inside the plugin. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficserver] shukitchan commented on issue #8291: ESI include does not process during getting 304 header

Posted by GitBox <gi...@apache.org>.
shukitchan commented on issue #8291:
URL: https://github.com/apache/trafficserver/issues/8291#issuecomment-908375204


   I don't think the ESI plugin currently supports the If-None-Match scenario. It can only transform a response from origin or a response from the cache. When status 304 is returned from origin, the body is empty and so there is nothing to transform. 
   
   you can instead try to remove "If-None-Match" header in the send request hook and so your origin will then not be able to send back 304 response. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficserver] shukitchan commented on issue #8291: ESI include does not process during getting 304 header

Posted by GitBox <gi...@apache.org>.
shukitchan commented on issue #8291:
URL: https://github.com/apache/trafficserver/issues/8291#issuecomment-998484414


   The script looks fine. I understand your intention of making ESI plugin to support 304 status response from origin as well. 
   
   However, my question is that status 304 is normally without a response body and so why would you want an ESI processing to happen on a 304 status response from origin? Can you give me a use case?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficserver] david187 commented on issue #8291: ESI include does not process during getting 304 header

Posted by GitBox <gi...@apache.org>.
david187 commented on issue #8291:
URL: https://github.com/apache/trafficserver/issues/8291#issuecomment-908383653


   um.
   I applied my lua patch, it seem to get cached response from cache store and process ESI include successfully.
   
   If the ESI plugin check the status code, and using the content-type in cached response if status code is 304.
   It should make ESI in ATS work fine with 304 header.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficserver] shukitchan closed issue #8291: ESI include does not process during getting 304 header

Posted by GitBox <gi...@apache.org>.
shukitchan closed issue #8291:
URL: https://github.com/apache/trafficserver/issues/8291


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficserver] shukitchan commented on issue #8291: ESI include does not process during getting 304 header

Posted by GitBox <gi...@apache.org>.
shukitchan commented on issue #8291:
URL: https://github.com/apache/trafficserver/issues/8291#issuecomment-908389040


   I see. So the lua script actually works for you? and it makes the plugin do a transform correctly. 
   
   Let me take a look.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficserver] david187 edited a comment on issue #8291: ESI include does not process during getting 304 header

Posted by GitBox <gi...@apache.org>.
david187 edited a comment on issue #8291:
URL: https://github.com/apache/trafficserver/issues/8291#issuecomment-908383653


   um.
   I applied my lua patch, it seem to get cached response from cache store and process ESI include successfully.
   
   If the ESI plugin check the status code, and using the content-type in cached response if status code is 304.
   It should make ESI in ATS work fine with 304 header.
   
   Supporting 304 header should make ATS response faster and can help to reduce bandwidth usage.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficserver] david187 edited a comment on issue #8291: ESI include does not process during getting 304 header

Posted by GitBox <gi...@apache.org>.
david187 edited a comment on issue #8291:
URL: https://github.com/apache/trafficserver/issues/8291#issuecomment-908383653


   um.
   I applied my lua patch, it seem to get cached response from cache store and process ESI include successfully.
   
   If the ESI plugin check the status code, and using the content-type in cached response if status code is 304.
   It should make ESI in ATS work fine with 304 header.
   
   Supporting 304 header should make ATS response faster and can help to reduce bandwidth usage.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org