CopyDisable

Monday 15 August 2011

Caching static content in Netscaler Load Balancer

In this blog post I will show how we can cache static contents like images, javascripts and cascading style sheets in Netscaler Load Balancer. In this example I am using Netscaler version 8.1: Build 68.7.

If Integrated Caching feature is not enabled in Netscaler we have to enable it. Login to Netscaler Management GUI and go to the Navigation Panel and expand the System Node. Click on basic features to open the Configure Basic Features window.

Check the Integrated Caching check box and click OK to enable Integrated Caching.





Step1: Creating policy expression

A policy expression is a set of conditions that can be applied on content entering the Netscaler. Netscaler has different features like Compression, Integrated Caching and Content Switching and these features share the policy expressions. Policy expressions control the Compression, Integrated Caching and Content Switching features. Policy Expressions can be created within the Feature or at the System node of the Netscaler GUI. The policy expressions created within System node are global to the system. In this example I am going to create global policy expressions within the System node. Creating policy expressions within System node has the benefit of centralized repository and it can be shared amongst all the features.
Login to Netscaler Management GUI and go to the System node and go to Expressions. In the right side Expressions panel we can see the existing policy expressions.



We are going to create five policy expressions for static content and for the following objects:
  1. gif (image)
  2. jpg (image)
  3. jpeg (image)
  4. js (javascript)
  5. css (cascading style sheet)
Click on the Add button to add new Policy Expression


 First expression we will create for gif images. Enter the expression name gif and click on Add button to add the expression statement.



We will add expression for gif type images. Select Expression Type
General, Flow Type
REQ, Protocol HTTP, Qualifier
URL, Operator
== and enter Value
*.gif in the Add Expression window. Click OK to add the expression.



Now again for gif image we will add one more expression in case the file extension is in uppercase. Select Expression Type
General, Flow Type
REQ, Protocol HTTP, Qualifier
URL, Operator
== and enter Value
*.GIF in the Add Expression window. Click OK to add the expression.



We can see the two expressions we just added as REQ.HTTP.URL==*.gif and REQ.HTTP.URL==*.GIF.
Click Create to create the policy expression.



Repeat the above steps for jpeg type images. Add two expressions REQ.HTTP.URL==*.jpeg and REQ.HTTP.URL==*.JPEG





Repeat the above steps for jpg type images. Add two expressions REQ.HTTP.URL==*.jpg and REQ.HTTP.URL==*.JPG




Repeat the above steps for css type. Add two expressions REQ.HTTP.URL==*.css and REQ.HTTP.URL==*.CSS



Repeat the above steps for js file. Add expression REQ.HTTP.URL==*.js



 In the Expressions panel we can see the five new expressions we have just added.





Step2: Creating Content Group:
To configure Static Caching, a Content Group must be created. Every object cached by the Integrated Caching feature is made a member of a Content Group. When an object is being downloaded and stored the association of the object and Content Group happens. We have to create caching policy which will drive this association. Expand the Integrated Caching node and click on Content Group. In the right side panel we can see the existing Content Groups. Click on Add button to create a Content Group.





We are going to create three different Content Groups:
  1. images (to store gif, jpeg/jpg images)
  2. javascript (to store the js files)
  3. css (to store css files)
Enter the Name as images.




We will change the memory settings of the Content Group. Go to the Memory tab. In the Do not cache, if size exceeds change the default value 80KB to the desired maximum size value of an object you want to cache. Here I want to cache object which are less than 500KB in size. Change the Maximum memory allocated in case you want to change the maximum memory allocated to this Content Group. Click Create to create the content group.


Same way we will add the other two content groups JavaScript and css.





Step3: Creating Policy:
The association between Content Group and an object is declared in a policy and that resulted in caching of the object. Now we have to create policies that will define the caching of the static contents. Click on Policies under the Integrated Caching node. Click on Add button to add a new policy.



First policy we will create to cache the images. Enter cache_images in Name field. Select CACHE in Action. Select the images Content Group from the Store in Group list. Select General in Named Expressions list. Select gif expression and click on the Add Expression button to add the gif expression to the cache_images policy.




Same way we will add the jpeg and jpg expressions to the cache_images policy. Click Create button to create the cache_images policy.



Same way will add the policy cache_js to cache the js files. Select Content Group javascript and expression js in this case.



Finally we will add policy cache_css to cache css files. Here we have to select css Content Group and css expression.



Our three policies are created and we can see them in the right side panel. The newly created policies are in PASSIVE state. To start the caching process we have to activate the policies. Click on the Activate Policies to activate the policies that we created.



The Cache Policy Activation/De-activation screen appears. Select the policy name and click the Add button.



Add all the policies that we have created and click OK.



Now we can see the policies as active. Also we can find the number of hits of each policy. So our Static Caching is started

জয় আই অসম,
প্রণব শর্মা

2 comments:

Anonymous said...

tnx

Anonymous said...

Pranab'S Scrapbook: Caching Static Content In Netscaler Load Balancer >>>>> Download Now

>>>>> Download Full

Pranab'S Scrapbook: Caching Static Content In Netscaler Load Balancer >>>>> Download LINK

>>>>> Download Now

Pranab'S Scrapbook: Caching Static Content In Netscaler Load Balancer >>>>> Download Full

>>>>> Download LINK

Post a Comment