Jump to content
Welcome to our new Citrix community!

Integrated caching, targetting and controlling


Kari Ruissalo

Recommended Posts

Hi,

 

I'm in process of implementing IC on a customer and my plan is to target the cache for a specific LB only (behind a CS vServer). The reason for this is that I could use the test address for ensuring that the IC works properly and doesn't cause issues with the web application.

 

What I've done so far:

  • Enabled the IC feature
  • Added a Content Group (Type = HTTP, default settings)
  • Created a Cache Policy with the following expression
Quote

HTTP.REQ.HOSTNAME.EQ("website-test.customer.com") && ( HTTP.REQ.URL.CONTAINS(".jpg") || HTTP.REQ.URL.CONTAINS(".jpeg") || HTTP.REQ.URL.CONTAINS(".png") || HTTP.REQ.URL.CONTAINS(".css") || HTTP.REQ.URL.CONTAINS(".js"))

 

  • Bound this policy to the LB vServer
  • Changed the IC global settings so that the memory limit is 500MB

 

The problem is that if I now view the Cached objects it seems to contain .svg, .eot, .woff files also and the host for these objects is the production one ("website.customer.com").

 

I'm aware that when you enable IC , it automatically does some stuff. How can I limit the caching for just that specific LB vServer?

Link to comment
Share on other sites

Yes, indeed, the built-in caching policies basically say "if the response doesn't say it shouldn't be cached, then cache it" (which pretty much what external caches and browser caches do).

 

To stop that, you could bind a "no-cache" policy somewhere.... you could bind it to global default (= above the built-in behaviour, but below the LBVS ones) to prevent caching anywhere else on your Netscaler

  • Like 1
Link to comment
Share on other sites

Thanks Paul. I suspected this might be the case. In this case caching static stuff should be safe but for the dynamic content I would like to avoid this. I think I'll apply the no-cache policy globally with a lower prio than the one I've bound to my vServer (I'll set that one also with an expression like "HTTP.REQ.HOSTNAME.EQ("website-test.customer.com").NOT"). This way I can limit the test for the specific host name and when it's confirmed not to cause issues I can just remove that policy.

 

Is it a performance-related thing that the Caching is set globally rather than per vServer?

 

edit: so there's actually no Policy that controls that "cache everything"? Just tried to find one without any luck :)

Edited by Kari Ruissalo
checked the configuration
Link to comment
Share on other sites

Yes, that's one, very valid, way to do it! The way I would probably do things is to add in a req & res pair of global default policies true --> nocache to kill caching generally, then bind in the specific policies to invoke caching.

 

You can bind cache policies to vservers (just run up the policy manager, and you'll see the vserver bindpoints), and that's probably the best way to do things, as (apart from the global default behaviour) you tend to want your "special cases" to be per vserver.

 

To see the "built in caching behaviour", you start by looking at the request & response Global Default bind points: there you'll see that each invokes a user-defined policy label.

So, now look at "policy labels", and you'll see _reqBuiltinDefaults (3 policies bound) and  _resBuiltinDefaults (8 policies bound). You'll find all of those actual policies listed under the Caching Policies.

Some of the policies specifically stop caching, some specifically allow caching, and after all those policies have happened, the way I read things is that anything else is allowed to be cached. There's no specific "cache anything else" policy, it's just the default behaviour (in the same way that AppFW, Compression all kick in when they are enabled.

 

Link to comment
Share on other sites

Thank you Paul!

 

So the cache is also working on the response process? That I didn't know... that explains why some stuff is still cached for the other vServers also. Can you explain why the cache is actually applied also on the response and not only for the request?

 

The way to circle around the response caching would be in my case just to implement a caching policy with expression "HTTP.RES.HOSTNAME.EQ("website-test.customer.com").NOT")?

Link to comment
Share on other sites

There are default cache policies that are bound to the request and response sides, and you can bind your policies to either.

 

Basically, the request side policies make decisions based on the INcoming request, and the response side policies are based on the OUTgoing responses (although they are also able to look at the request settings too!)

 

The request and response side polices can interact, but always "fail safe" in that if EITHER request or response gives a NOCACHE, then it will NOT be cached. The best thing to do is to read the docs, where the req / resp interaction is described.

 

The response side is very important, as that's where the caching headers are (which is part of what the default policies are looking at)

Link to comment
Share on other sites

  • 4 weeks later...

I have now tried pretty much everything to prevent caching on a test hostname, but the IC still seems to keep the files in cache.

 

I have created a caching policy for the LB:

add cache policy ic_pol_nocache-lb -rule true -action NOCACHE

... and bound this for the LB on both response and request.

 

I have created a global policy for the specific host name to prevent caching:

add cache policy ic_pol_nocache -rule "HTTP.REQ.HOSTNAME.EQ(\"dev.customer.com\").NOT" -action NOCACHE

... and bound this for both response and request.

 

Still the developers complain that their .js files are in the cache and don't get updated.

Link to comment
Share on other sites

Do remember that, if for any reason, an object is already in the cache, then it will be served out of cache, ignoring the cache policies..., even if you subsequently add a policy changing the rules.... so you need to flush the cache if you make changes.

 

I wonder if the oject is getting into cache from somewhere else, and then Netscaler is seeing it and serving it from cache when you're not expecing it to do so. Take a look at the docs, homing in on (I think) the phrase Parameterisation

 

Finally, are you happy that the NoCache policy IS getting hits when you expect it? I read the policy above to say "if it's NOT the dev server, don't cache"... it needs to be bound at a very hight precedence, so maybe global-override, or first on a vserver.

 

How MUCH unexpected data is being cached? Are we talking lots of pages, or just one or two specific .js pages? (And do those url's get used elswhere

  • Like 1
Link to comment
Share on other sites

On 2/8/2018 at 6:51 PM, Paul Blitz said:

Finally, are you happy that the NoCache policy IS getting hits when you expect it? I read the policy above to say "if it's NOT the dev server, don't cache"... it needs to be bound at a very hight precedence, so maybe global-override, or first on a vserver.

 

Thank you Paul. It was actually the .NOT in the expression that caused my problems. That was left there because originally I enabled the caching for the test address. This can be marked as answered now. :)

Link to comment
Share on other sites

  • 1 year later...

I am wondering same things that  how to safely enable Intgrated Cache  IC for LB instance which have many important production service virtual servers (vips).
I would like to enable cache only for one new VIP and restrict rest of vips from any request or response side caching.

 

I have configured this kind of setup for my LB:

 

-Cache content group with default settings:

add cache contentGroup COMPANY-CG 

 

-Policy which checks HTTP GET request towards test.company.com address with certain filetypes which we wanted to be served from IC:

add cache policy company-cache-pol -rule "HTTP.REQ.METHOD.EQ(\"GET\")&&HTTP.REQ.HOSTNAME.EQ(\"test.company.com\")&&( HTTP.REQ.URL.CONTAINS(\".png\") || HTTP.REQ.URL.CONTAINS(\".css\") || HTTP.REQ.URL.CONTAINS(\".js\"))" -action CACHE -storeInGroup COMPANY-CG

 

-Policy which quarantees that anything else is not cached towards VIP by default:

add cache policy nocache-pol -rule true -action NOCACHE

 

-Binding policies with VIP:
bind lb vserver test.company.com-vip -policyName company-cache-pol -priority 100 -gotoPriorityExpression END -type REQUEST
bind lb vserver test.company.com-vip -policyName nocache-pol  -priority 110 -gotoPriorityExpression END -type REQUEST

 

-Global Override policy which quarantees that if request does not include test.company.com anything else is not cached globally in LB:
add cache policy nocache-override-pol -rule "HTTP.REQ.HOSTNAME.EQ(\"test.company.com\").NOT" -action NOCACHE
bind cache global nocache-override-pol -priority 100 -gotoPriorityExpression END -type REQ_OVERRIDE

 

Does this type configuration sound sensible and is it safe to enable IC for our production environment? :)

Do I need to modify  response side IC configurations also? I am little bit confused with Netscaler documentation related to this IC and this request/response side caching.   Documentation is missing configuration examples as usual. 

I would like to keep my setup as simple as possible and maybe later optimize IC settings a step by step.     

For instance I would like serve from cache all request which include following MIME types:

text/html,text/css,text/plain,text/xml,text/javascript,application/x-javascript,application/javascript

 

But I do not know yet how to implement this.   Any tips are more than welcome. :)

 

 

 

On 2/8/2018 at 6:51 PM, Paul Blitz said:

Do remember that, if for any reason, an object is already in the cache, then it will be served out of cache, ignoring the cache policies..., even if you subsequently add a policy changing the rules.... so you need to flush the cache if you make changes.

 

I wonder if the oject is getting into cache from somewhere else, and then Netscaler is seeing it and serving it from cache when you're not expecing it to do so. Take a look at the docs, homing in on (I think) the phrase Parameterisation

 

Finally, are you happy that the NoCache policy IS getting hits when you expect it? I read the policy above to say "if it's NOT the dev server, don't cache"... it needs to be bound at a very hight precedence, so maybe global-override, or first on a vserver.

 

How MUCH unexpected data is being cached? Are we talking lots of pages, or just one or two specific .js pages? (And do those url's get used elswhere

 

Link to comment
Share on other sites

  • 2 years later...
On 1/8/2018 at 10:10 AM, Paul Blitz said:

Yes, indeed, the built-in caching policies basically say "if the response doesn't say it shouldn't be cached, then cache it" (which pretty much what external caches and browser caches do).

 

To stop that, you could bind a "no-cache" policy somewhere.... you could bind it to global default (= above the built-in behaviour, but below the LBVS ones) to prevent caching anywhere else on your Netscaler

Can I just unbind the default policies from the Default Global policy bind point rather than creating a NoCache Policy and binding it before the built-in policies on the Default Global?  This would make more sense to me because there is less evaluation done by the Netscaler.  I am unsure if unbinding those "default" built-in policies could impact future upgrades, ect.  

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...