You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@trafficserver.apache.org by Jason Yang <pe...@gmail.com> on 2019/03/27 18:49:29 UTC

check whether it will be a hit on trafficserver

Hi community, 
    Is there anyway to check whether a request will be a hit or miss without having trafficserver serving any content and not going to origin? (I think I can do HEAD, but it goes to origin). Thank you! 


Best, 
Jason 

Re: [EXTERNAL] Re: check whether it will be a hit on trafficserver

Posted by Jason Yang <pe...@gmail.com>.
Hi Bryan, Miles and Brennan, 
    The tool is really useful, I wish I knew it earlier. :) 
    And I think what Miles has proposed is what I need, I want to fetch the response from ATS only when it is cached, if it is not, I go other routes. Thank you very much! 


Jason 


> On Mar 27, 2019, at 17:19, Fieck, Brennan <Br...@comcast.com> wrote:
> 
> I think `-IXGET` will cause *curl* to drop the body - ATS still serves it to you. Assuming ATS respects that Cache-Control header, then you should be fine to just send a `HEAD` request if you don't want the body. Although I think for objects that are less than up to (roughly) equal to the average object size, fetching the body will be a negligible additional cost as far as ATS is concerned.
> 
> If what you're trying to do is see what's stored in your cache, I shamelessly recommend the buggy-but-useful Superior Cache ANalyzer (SCAN) tool: https://github.com/comcast/superior-cache-analyzer
> ________________________________________
> From: Miles Libbey <ml...@apache.org>
> Sent: Wednesday, March 27, 2019 3:10 PM
> To: users@trafficserver.apache.org
> Subject: [EXTERNAL] Re: check whether it will be a hit on trafficserver
> 
> I do:
> curl -IXGET -H "Cache-Control: only-if-cached" "https://protect2.fireeye.com/url?k=918b742c9b1bbda4.918b5398-c36456a0d5da6c67&u=http://myurlhere"
> 
> The -IXGET makes it do a GET, but, drops the body. The Cache-Control:
> only-if-cached request header will have ATS respond with a 200 if the
> object is in cache, otherwise you get a 504 if not in cache.
> 
> miles
> 
> 
> On Wed, Mar 27, 2019 at 11:49 AM Jason Yang <pe...@gmail.com> wrote:
>> 
>> Hi community,
>>    Is there anyway to check whether a request will be a hit or miss without having trafficserver serving any content and not going to origin? (I think I can do HEAD, but it goes to origin). Thank you!
>> 
>> 
>> Best,
>> Jason


Re: [EXTERNAL] Re: check whether it will be a hit on trafficserver

Posted by "Fieck, Brennan" <Br...@comcast.com>.
I think `-IXGET` will cause *curl* to drop the body - ATS still serves it to you. Assuming ATS respects that Cache-Control header, then you should be fine to just send a `HEAD` request if you don't want the body. Although I think for objects that are less than up to (roughly) equal to the average object size, fetching the body will be a negligible additional cost as far as ATS is concerned.

If what you're trying to do is see what's stored in your cache, I shamelessly recommend the buggy-but-useful Superior Cache ANalyzer (SCAN) tool: https://github.com/comcast/superior-cache-analyzer
________________________________________
From: Miles Libbey <ml...@apache.org>
Sent: Wednesday, March 27, 2019 3:10 PM
To: users@trafficserver.apache.org
Subject: [EXTERNAL] Re: check whether it will be a hit on trafficserver

I do:
curl -IXGET -H "Cache-Control: only-if-cached" "https://protect2.fireeye.com/url?k=918b742c9b1bbda4.918b5398-c36456a0d5da6c67&u=http://myurlhere"

The -IXGET makes it do a GET, but, drops the body. The Cache-Control:
only-if-cached request header will have ATS respond with a 200 if the
object is in cache, otherwise you get a 504 if not in cache.

miles


On Wed, Mar 27, 2019 at 11:49 AM Jason Yang <pe...@gmail.com> wrote:
>
> Hi community,
>     Is there anyway to check whether a request will be a hit or miss without having trafficserver serving any content and not going to origin? (I think I can do HEAD, but it goes to origin). Thank you!
>
>
> Best,
> Jason

Re: check whether it will be a hit on trafficserver

Posted by Miles Libbey <ml...@apache.org>.
I do:
curl -IXGET -H "Cache-Control: only-if-cached" "http://myurlhere"

The -IXGET makes it do a GET, but, drops the body. The Cache-Control:
only-if-cached request header will have ATS respond with a 200 if the
object is in cache, otherwise you get a 504 if not in cache.

miles


On Wed, Mar 27, 2019 at 11:49 AM Jason Yang <pe...@gmail.com> wrote:
>
> Hi community,
>     Is there anyway to check whether a request will be a hit or miss without having trafficserver serving any content and not going to origin? (I think I can do HEAD, but it goes to origin). Thank you!
>
>
> Best,
> Jason

Re: check whether it will be a hit on trafficserver

Posted by Bryan Call <bc...@apache.org>.
In most cases, unless you are overriding if a response can be cached, you will have to go to the origin.  The headers in the response from the origin tells the proxy server if it can be cached or not.

-Bryan



> On Mar 27, 2019, at 11:49 AM, Jason Yang <pe...@gmail.com> wrote:
> 
> Hi community, 
>    Is there anyway to check whether a request will be a hit or miss without having trafficserver serving any content and not going to origin? (I think I can do HEAD, but it goes to origin). Thank you! 
> 
> 
> Best, 
> Jason