You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@trafficserver.apache.org by Jorge Román Novalbos <jr...@linux-it.es> on 2012/11/10 09:31:17 UTC

URL Hash

Hi everybody!

I have a big problem, I'm using TS as reverse proxy and i'm trying to cache a simple web site.
Everything is working fine but when the user is logged in the site. In that moment the nickname should be shown at top of the page but it doesn't happen because the url has been cached priorly with the same url.

For example:

- www.example.com/cart is cached without any user logged in. Then a user is logged in the site the page shown is the first one (the page within user logged in) instead the page with the nickname at top.

My question, It is posible to cache two different version to the same url depending if a cookie in present or not??. 

Thank in advance.

Jorge

RE: URL Hash

Posted by Luca Rea <lu...@contactlab.com>.
I was thinking to use lua in the following way:

1) lua remap: if cookie is there the plugin rewrite url into " http://nocache.com"
2) remap.config: map http://nocache.com http://www.mysite.com
3) cache.config: dest_domain=nocache.com action=never-cache

Can something like that be a possible solution?

Re: URL Hash

Posted by Jorge Román Novalbos <jr...@linux-it.es>.
WP is sending one cookie from the plugin Mobile Website Detector (websitez_mobile_detector), besides other cookies are sent from the server like google analytics cookies (__utma, __utmb …). 
Really when the user is logged in the site the wordpress_logged_in_e1b30b5b176d5cfe63955c27f6f1d510 is create in this case.

I would like to serve one version of site to all anonimous user from cache and when the worpress_logged_in cookie is present serve one no cache version.

Is not a problem of WP of course, this problem is extending to any web page with private zone.

Any idea?









On 11/11/2012, at 02:16, Kurt Payne <kp...@gmail.com> wrote:

> Which cookies are sent from WordPress when the user is not logged in?
> 
> --Kurt
> 
> On Nov 10, 2012 5:02 PM, "Leif Hedstrom" <zw...@apache.org> wrote:
> On 11/10/12 1:57 AM, Jorge Román Novalbos wrote:
> Hi Alex,
> 
> I have proxy.config.http.cache.cache_responses_to_cookie configured to 1, I mean to cache all content although the cookie is present.
> If I set that param to 3, the html is not cached and all html content go back to the origin servera, so it is not valid for me.
> 
> As you say, the site send a cookie when the user is logged (wp_loggin) in but the problem is when there is not user logged in, other types of cookies are sent too.
> 
> I'm using a Wordpress as a backend server and I can modify the code.
> 
> I could have sworn Wordpress took care of this by default, by making sure that "personalize" content is not cacheable. Cc:ing Kurt Payne (not sure if he's listening in on this channel):  How did you set this up with ATS?
> 
> -- Leif
> 


Re: URL Hash

Posted by Leif Hedstrom <zw...@apache.org>.
On 11/10/12 1:57 AM, Jorge Román Novalbos wrote:
> Hi Alex,
>
> I have proxy.config.http.cache.cache_responses_to_cookie configured to 1, 
> I mean to cache all content although the cookie is present.
> If I set that param to 3, the html is not cached and all html content go 
> back to the origin servera, so it is not valid for me.
>
> As you say, the site send a cookie when the user is logged (wp_loggin) in 
> but the problem is when there is not user logged in, other types of 
> cookies are sent too.
>
> I'm using a Wordpress as a backend server and I can modify the code.

I could have sworn Wordpress took care of this by default, by making sure 
that "personalize" content is not cacheable. Cc:ing Kurt Payne (not sure if 
he's listening in on this channel):  How did you set this up with ATS?

-- Leif


Re: URL Hash

Posted by James Peach <jp...@apache.org>.
On 10/11/2012, at 10:22 AM, Jorge Román Novalbos <jr...@linux-it.es> wrote:

> Could it be posible to do that i want with LUA plugin???

You can use the lua plugin to alter the configuration for specific requests.

> 
> summarizing: I want to cache the all object by default (proxy.config.http.cache.cache_responses_to_cookies INT 1) and when a loggin cookie is present I don't want to cache and a diferent hash should be kept.

Maybe you could detect the cookie, then alter the request configuration and set a Vary header to generate the alternate hash?

> 
> Thanks in advance.
> 
> 
> On 10/11/2012, at 09:57, Jorge Román Novalbos <jr...@linux-it.es> wrote:
> 
>> Hi Alex, 
>> 
>> I have proxy.config.http.cache.cache_responses_to_cookie configured to 1, I mean to cache all content although the cookie is present.
>> If I set that param to 3, the html is not cached and all html content go back to the origin servera, so it is not valid for me.
>> 
>> As you say, the site send a cookie when the user is logged (wp_loggin) in but the problem is when there is not user logged in, other types of cookies are sent too.
>> 
>> I'm using a Wordpress as a backend server and I can modify the code.
>> 
>> In varnish you can create a different hash if an determinare object is present or not (like a cookie in this case).
>> 
>> Thanks!
>> 
>> 
>> On 10/11/2012, at 09:47, Aleksandrs Andrijenko <in...@eurohosting.lv> wrote:
>> 
>>> Hi Jorge,
>>> 
>>> I think you must have some cookies set when the user is logged id, to identify the session.
>>> 
>>> By default ATS is not caching Cookie header.
>>> 
>>> In that case you need to enable cookie header to be cached and not skipped in records.config.
>>> 
>>> proxy.config.http.cache.cache_responses_to_cookies 1;
>>> 
>>> Or see documentation of this parameter: 
>>> Set this variable to specify how Traffic Server caches cookied content:
>>>   0 = Do not cache any responses to cookies. 
>>>   1 = Cache all responses to cookies. 
>>>   2 = Cache responses to cookies of image type only. 
>>>   3 = Cache all responses to cookies except text content-types (the default)..
>>> 
>>> I hope it will resolve your issue.
>>> 
>>> Regards,
>>> Alex
>>> 
>>>  
>>> On Nov 10, 2012, at 9:31 AM, Jorge Román Novalbos wrote:
>>> 
>>>> Hi everybody!
>>>> 
>>>> I have a big problem, I'm using TS as reverse proxy and i'm trying to cache a simple web site.
>>>> Everything is working fine but when the user is logged in the site. In that moment the nickname should be shown at top of the page but it doesn't happen because the url has been cached priorly with the same url.
>>>> 
>>>> For example:
>>>> 
>>>> - www.example.com/cart is cached without any user logged in. Then a user is logged in the site the page shown is the first one (the page within user logged in) instead the page with the nickname at top.
>>>> 
>>>> My question, It is posible to cache two different version to the same url depending if a cookie in present or not??. 
>>>> 
>>>> Thank in advance.
>>>> 
>>>> Jorge
>>> 
>> 
> 


Re: URL Hash

Posted by James Peach <jp...@apache.org>.
On 10/11/2012, at 10:44 AM, "Alan M. Carroll" <am...@network-geographics.com> wrote:

> Saturday, November 10, 2012, 12:22:07 PM, you wrote:
> 
>> Could it be posible to do that i want with LUA plugin???
> 
> You could easily do it with a normal plugin, you don't need LUA unless you prefer it.

Is it possible without a plugin?

J

Re: URL Hash

Posted by James Peach <jp...@apache.org>.
On 10/11/2012, at 10:44 AM, "Alan M. Carroll" <am...@network-geographics.com> wrote:

> Saturday, November 10, 2012, 12:22:07 PM, you wrote:
> 
>> Could it be posible to do that i want with LUA plugin???
> 
> You could easily do it with a normal plugin, you don't need LUA unless you prefer it.

Is it possible without a plugin?

J

Re: URL Hash

Posted by "Alan M. Carroll" <am...@network-geographics.com>.
Saturday, November 10, 2012, 12:22:07 PM, you wrote:

> Could it be posible to do that i want with LUA plugin???

You could easily do it with a normal plugin, you don't need LUA unless you prefer it.


Re: URL Hash

Posted by "Alan M. Carroll" <am...@network-geographics.com>.
It's documented in the file, but to be explicit

You want to edit the etc/trafficserver/cache.config file.

You can set up a URL match with either dest_domain or url_regex. You might want dest_domain in your situation. With each match you can control some of the cache parameters, including whether cookie responses are cached. So

dest_domain=www.example_domain.com prefix=cart action=ignore-server-no-cache cache-responses-to-cookies=0

Unfortunately you must have a cache action in addition to the cookie parameter, so you'll have to pick one.

Saturday, November 10, 2012, 1:27:33 PM, you wrote:

> Hi Alan, 

> Could you explain how to do that? 

> Thanks!

> Jorge Roman Novalbos
> jroman@servotic.com
> 679 99 08 62
> http://www.servotic.com

> On 10/11/2012, at 19:50, "Alan M. Carroll" <am...@network-geographics.com> wrote:

>> You can do something similar with the cache.config file. With that you can match URLs by regex and then tweak the cache_responses_to_cookies value just those URLs with the "cache-responses-to-cookies" option.

>> Saturday, November 10, 2012, 12:22:07 PM, you wrote:
>>> summarizing: I want to cache the all object by default (proxy.config.http.cache.cache_responses_to_cookies INT 1) and when a loggin cookie is present I don't want to cache and a diferent hash should be kept.



Re: URL Hash

Posted by "Linux-it.es" <jr...@linux-it.es>.
Hi Alan, 

Could you explain how to do that? 

Thanks!

Jorge Roman Novalbos
jroman@servotic.com
679 99 08 62
http://www.servotic.com

On 10/11/2012, at 19:50, "Alan M. Carroll" <am...@network-geographics.com> wrote:

> You can do something similar with the cache.config file. With that you can match URLs by regex and then tweak the cache_responses_to_cookies value just those URLs with the "cache-responses-to-cookies" option.
> 
> Saturday, November 10, 2012, 12:22:07 PM, you wrote:
>> summarizing: I want to cache the all object by default (proxy.config.http.cache.cache_responses_to_cookies INT 1) and when a loggin cookie is present I don't want to cache and a diferent hash should be kept.
> 

Re: URL Hash

Posted by "Alan M. Carroll" <am...@network-geographics.com>.
You can do something similar with the cache.config file. With that you can match URLs by regex and then tweak the cache_responses_to_cookies value just those URLs with the "cache-responses-to-cookies" option.

Saturday, November 10, 2012, 12:22:07 PM, you wrote:
> summarizing: I want to cache the all object by default (proxy.config.http.cache.cache_responses_to_cookies INT 1) and when a loggin cookie is present I don't want to cache and a diferent hash should be kept.


Re: URL Hash

Posted by Jorge Román Novalbos <jr...@linux-it.es>.
Could it be posible to do that i want with LUA plugin???

summarizing: I want to cache the all object by default (proxy.config.http.cache.cache_responses_to_cookies INT 1) and when a loggin cookie is present I don't want to cache and a diferent hash should be kept.

Thanks in advance.


On 10/11/2012, at 09:57, Jorge Román Novalbos <jr...@linux-it.es> wrote:

> Hi Alex, 
> 
> I have proxy.config.http.cache.cache_responses_to_cookie configured to 1, I mean to cache all content although the cookie is present.
> If I set that param to 3, the html is not cached and all html content go back to the origin servera, so it is not valid for me.
> 
> As you say, the site send a cookie when the user is logged (wp_loggin) in but the problem is when there is not user logged in, other types of cookies are sent too.
> 
> I'm using a Wordpress as a backend server and I can modify the code.
> 
> In varnish you can create a different hash if an determinare object is present or not (like a cookie in this case).
> 
> Thanks!
> 
> 
> On 10/11/2012, at 09:47, Aleksandrs Andrijenko <in...@eurohosting.lv> wrote:
> 
>> Hi Jorge,
>> 
>> I think you must have some cookies set when the user is logged id, to identify the session.
>> 
>> By default ATS is not caching Cookie header.
>> 
>> In that case you need to enable cookie header to be cached and not skipped in records.config.
>> 
>> proxy.config.http.cache.cache_responses_to_cookies 1;
>> 
>> Or see documentation of this parameter: 
>> Set this variable to specify how Traffic Server caches cookied content:
>>   0 = Do not cache any responses to cookies. 
>>   1 = Cache all responses to cookies. 
>>   2 = Cache responses to cookies of image type only. 
>>   3 = Cache all responses to cookies except text content-types (the default)..
>> 
>> I hope it will resolve your issue.
>> 
>> Regards,
>> Alex
>> 
>>  
>> On Nov 10, 2012, at 9:31 AM, Jorge Román Novalbos wrote:
>> 
>>> Hi everybody!
>>> 
>>> I have a big problem, I'm using TS as reverse proxy and i'm trying to cache a simple web site.
>>> Everything is working fine but when the user is logged in the site. In that moment the nickname should be shown at top of the page but it doesn't happen because the url has been cached priorly with the same url.
>>> 
>>> For example:
>>> 
>>> - www.example.com/cart is cached without any user logged in. Then a user is logged in the site the page shown is the first one (the page within user logged in) instead the page with the nickname at top.
>>> 
>>> My question, It is posible to cache two different version to the same url depending if a cookie in present or not??. 
>>> 
>>> Thank in advance.
>>> 
>>> Jorge
>> 
> 


Re: URL Hash

Posted by Jorge Román Novalbos <jr...@linux-it.es>.
Hi Alex, 

I have proxy.config.http.cache.cache_responses_to_cookie configured to 1, I mean to cache all content although the cookie is present.
If I set that param to 3, the html is not cached and all html content go back to the origin servera, so it is not valid for me.

As you say, the site send a cookie when the user is logged (wp_loggin) in but the problem is when there is not user logged in, other types of cookies are sent too.

I'm using a Wordpress as a backend server and I can modify the code.

In varnish you can create a different hash if an determinare object is present or not (like a cookie in this case).

Thanks!


On 10/11/2012, at 09:47, Aleksandrs Andrijenko <in...@eurohosting.lv> wrote:

> Hi Jorge,
> 
> I think you must have some cookies set when the user is logged id, to identify the session.
> 
> By default ATS is not caching Cookie header.
> 
> In that case you need to enable cookie header to be cached and not skipped in records.config.
> 
> proxy.config.http.cache.cache_responses_to_cookies 1;
> 
> Or see documentation of this parameter: 
> Set this variable to specify how Traffic Server caches cookied content:
>   0 = Do not cache any responses to cookies. 
>   1 = Cache all responses to cookies. 
>   2 = Cache responses to cookies of image type only. 
>   3 = Cache all responses to cookies except text content-types (the default)..
> 
> I hope it will resolve your issue.
> 
> Regards,
> Alex
> 
>  
> On Nov 10, 2012, at 9:31 AM, Jorge Román Novalbos wrote:
> 
>> Hi everybody!
>> 
>> I have a big problem, I'm using TS as reverse proxy and i'm trying to cache a simple web site.
>> Everything is working fine but when the user is logged in the site. In that moment the nickname should be shown at top of the page but it doesn't happen because the url has been cached priorly with the same url.
>> 
>> For example:
>> 
>> - www.example.com/cart is cached without any user logged in. Then a user is logged in the site the page shown is the first one (the page within user logged in) instead the page with the nickname at top.
>> 
>> My question, It is posible to cache two different version to the same url depending if a cookie in present or not??. 
>> 
>> Thank in advance.
>> 
>> Jorge
> 


Re: URL Hash

Posted by Aleksandrs Andrijenko <in...@eurohosting.lv>.
Hi Jorge,

I think you must have some cookies set when the user is logged id, to identify the session.

By default ATS is not caching Cookie header.

In that case you need to enable cookie header to be cached and not skipped in records.config.

proxy.config.http.cache.cache_responses_to_cookies 1;

Or see documentation of this parameter: 
Set this variable to specify how Traffic Server caches cookied content:
  0 = Do not cache any responses to cookies. 
  1 = Cache all responses to cookies. 
  2 = Cache responses to cookies of image type only. 
  3 = Cache all responses to cookies except text content-types (the default)..

I hope it will resolve your issue.

Regards,
Alex

 
On Nov 10, 2012, at 9:31 AM, Jorge Román Novalbos wrote:

> Hi everybody!
> 
> I have a big problem, I'm using TS as reverse proxy and i'm trying to cache a simple web site.
> Everything is working fine but when the user is logged in the site. In that moment the nickname should be shown at top of the page but it doesn't happen because the url has been cached priorly with the same url.
> 
> For example:
> 
> - www.example.com/cart is cached without any user logged in. Then a user is logged in the site the page shown is the first one (the page within user logged in) instead the page with the nickname at top.
> 
> My question, It is posible to cache two different version to the same url depending if a cookie in present or not??. 
> 
> Thank in advance.
> 
> Jorge