You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@trafficserver.apache.org by Am...@cognizant.com on 2016/04/07 00:53:59 UTC

Traffic cache config for only 200 status response

Hi Team,

Need inputs from anyone who knows how to ask Trafficserver only to have response status 200/ok data in the cache. I want to stop trafficserver to cache 404 status responses which sometimes makes the app malfunction until I don't go manually in the cache and remove that forcing Trafficserver to re-cache the file.

Thanks,
Amit
This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information. If you are not the intended recipient(s), please reply to the sender and destroy all copies of the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this email, and/or any action taken in reliance on the contents of this e-mail is strictly prohibited and may be unlawful. Where permitted by applicable law, this e-mail and other e-mail communications sent to and from Cognizant e-mail addresses may be monitored.

Re: Traffic cache config for only 200 status response

Posted by Sudheer Vinukonda <su...@yahoo-inc.com.INVALID>.
Yeah, Leif's config should definitely work :)


About the http.cache setting, I was under the same impression (that it was too late to set it at READ_RESPONSE hook) as Leif until recently, when I accidentally saw that the code actually checks that setting at the read_response hook as well (it may not have been necessarily intentional, but, it seems to give additional flexibility).

So, in theory, at least both configs should work as far as not caching it goes.

One potential problem with adding <Cache-Control: no-cache, no-store> as opposed to simply disabling the http.cache setting is that, one might need to restore the origin's Cache-Control setting again at SEND_RESPONSE_HDR_HOOK (depending on whether they care about what the clients see/do), else the client will see the "no-cache, no-store" as well.




On Thursday, April 7, 2016 2:46 PM, Steve Malenfant <sm...@gmail.com> wrote:



I use what Leif said and it works great. Our problem was origin sending
cache control and expire headers and negative response. Looks like the
negative caching param doesn't work as intended. I meant to send something
about it but could never get around testing it properly.


On Wednesday, April 6, 2016, Leif Hedstrom <zw...@apache.org> wrote:

>
> > On Apr 6, 2016, at 8:02 PM, Sudheer Vinukonda
> <su...@yahoo-inc.com.INVALID> wrote:
> >
> > There's probably several ways of doing this (such as, disabling
> negative_caching etc), but, the most reliable way is to use header_rewrite
> to turn off http.cache on a non-200 response.
> >
> > Below's a sample config (I didn't test it myself, so, it may need some
> twiddling around):
> >
> > % cat plugin.config
> > header_rewrite.so negative_caching.config
> >
> >
> > % cat negative_caching.config
> >
> > cond %{READ_RESPONSE_HDR_HOOK} [AND]
> > cond %{STATUS} >=400
> > set-config proxy.config.http.cache.http 0 [L]
>
>
> Pretty sure that would not work, but try it. If it doesn’t work, then
> change it to something like
>
>         cond %{READ_RESPONSE_HDR_HOOK} [AND]
>         cond %{STATUS} >=400
>         set-header Cache-Control no-store,private
>
> or some such. I think turning off the cache at this stage is too late.
>
> — leif
>
>

Re: Traffic cache config for only 200 status response

Posted by Steve Malenfant <sm...@gmail.com>.
I use what Leif said and it works great. Our problem was origin sending
cache control and expire headers and negative response. Looks like the
negative caching param doesn't work as intended. I meant to send something
about it but could never get around testing it properly.

On Wednesday, April 6, 2016, Leif Hedstrom <zw...@apache.org> wrote:

>
> > On Apr 6, 2016, at 8:02 PM, Sudheer Vinukonda
> <su...@yahoo-inc.com.INVALID> wrote:
> >
> > There's probably several ways of doing this (such as, disabling
> negative_caching etc), but, the most reliable way is to use header_rewrite
> to turn off http.cache on a non-200 response.
> >
> > Below's a sample config (I didn't test it myself, so, it may need some
> twiddling around):
> >
> > % cat plugin.config
> > header_rewrite.so negative_caching.config
> >
> >
> > % cat negative_caching.config
> >
> > cond %{READ_RESPONSE_HDR_HOOK} [AND]
> > cond %{STATUS} >=400
> > set-config proxy.config.http.cache.http 0 [L]
>
>
> Pretty sure that would not work, but try it. If it doesn’t work, then
> change it to something like
>
>         cond %{READ_RESPONSE_HDR_HOOK} [AND]
>         cond %{STATUS} >=400
>         set-header Cache-Control no-store,private
>
> or some such. I think turning off the cache at this stage is too late.
>
> — leif
>
>

Re: Traffic cache config for only 200 status response

Posted by Leif Hedstrom <zw...@apache.org>.
> On Apr 6, 2016, at 8:02 PM, Sudheer Vinukonda <su...@yahoo-inc.com.INVALID> wrote:
> 
> There's probably several ways of doing this (such as, disabling negative_caching etc), but, the most reliable way is to use header_rewrite to turn off http.cache on a non-200 response.
> 
> Below's a sample config (I didn't test it myself, so, it may need some twiddling around):
> 
> % cat plugin.config
> header_rewrite.so negative_caching.config
> 
> 
> % cat negative_caching.config
> 
> cond %{READ_RESPONSE_HDR_HOOK} [AND]
> cond %{STATUS} >=400
> set-config proxy.config.http.cache.http 0 [L]


Pretty sure that would not work, but try it. If it doesn’t work, then change it to something like

	cond %{READ_RESPONSE_HDR_HOOK} [AND]
	cond %{STATUS} >=400
	set-header Cache-Control no-store,private

or some such. I think turning off the cache at this stage is too late.

— leif


Re: Traffic cache config for only 200 status response

Posted by Sudheer Vinukonda <su...@yahoo-inc.com.INVALID>.
There's probably several ways of doing this (such as, disabling negative_caching etc), but, the most reliable way is to use header_rewrite to turn off http.cache on a non-200 response.

Below's a sample config (I didn't test it myself, so, it may need some twiddling around):

% cat plugin.config
header_rewrite.so negative_caching.config


% cat negative_caching.config

cond %{READ_RESPONSE_HDR_HOOK} [AND]
cond %{STATUS} >=400
set-config proxy.config.http.cache.http 0 [L]



Thanks,

Sudheer



On Wednesday, April 6, 2016 3:53 PM, "Amit.Sharma-2@cognizant.com" <Am...@cognizant.com> wrote:



Hi Team,

Need inputs from anyone who knows how to ask Trafficserver only to have response status 200/ok data in the cache. I want to stop trafficserver to cache 404 status responses which sometimes makes the app malfunction until I don't go manually in the cache and remove that forcing Trafficserver to re-cache the file.

Thanks,
Amit
This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information. If you are not the intended recipient(s), please reply to the sender and destroy all copies of the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this email, and/or any action taken in reliance on the contents of this e-mail is strictly prohibited and may be unlawful. Where permitted by applicable law, this e-mail and other e-mail communications sent to and from Cognizant e-mail addresses may be monitored.