Citrix NetScaler comes with a caching feature named Integrated Caching which can cache frequently accessed data to take the stress off backend servers and deliver content to users faster by elminating trips to backend servers.
The cached data is stored in RAM on the NetScaler appliance or SSD on MPX appliances. Integrated Caching is shipped with NetScaler Platinum or as an add-on license if using NetScaler Enterprise licenses.
To enable Integrated Caching, navigate to System -> Settings -> Configure Basic Features -> Integrated Caching or via CLI run command enable ns feature ic.
Next you need to allocate an amount of memory to store caching objects. You can allocate up to half of the NetScaler’s memory to cache however Citrix recommend allocating less than half. To configure memory allocation, navigate to Optimization -> Integrated Caching -> Change cache settings -> Memory Usage Limit (MB).
The caching policies themselves are made up of three settings:
- Actions – Cache, do not cache etc.
- Store in group – Store content in which content group.
- Expression – The rule which needs to be matched before the policy is actioned.
Note: A Content Group contains settings such as when the cached content is set to expire and to not cache objects of a certain size.
To create a Content Group navigate to Optimization -> Integrated Caching -> Content Groups -> Add.
To create a cache policy navigate to Optimization -> Integrated Caching -> Policies -> Add.
Notice I used an expression of HTTP.REQ.HOSTNAME.CONTAINS(“storefront.citrixpro.co.uk”) which will cache all objects where the URL hostname contains storefront.citrixpro.co.uk. You could also use an expression that caches only PDF files or other file types.
To bind the policy to a vServer, navigate to Traffic Management -> Load Balancing -> Virtual Servers.
Edit an existing Virtual Server and under Policies click Add.
Under Choose Policy select Cache and under Choose Type select Request. Click Continue.
Click Click to select under Select Policy.
Choose the recently created policy and click Select.
Now click Bind.
You can also bind cache policies to LB vServers by navigating to Optimization -> Integrated Caching -> Cache Policy Manager.
Now when users hit the LB vServer all cacheable content will be cached. We can navigate to Dashboard -> Integrated Cache and Cache Policies to view statistics and see the new cache policy being hit.
You can also browse to Optimization -> Integrated Caching -> View Cache Objects.
Here you can get details on specific cached objects, expire or flush objects.
Clicking the Details button shows information such as the Content Group that stores the cached object.
When creating a Content Group consider the following settings:
- Do not cache – if size is less than – This prevents objects that are too small in size from being cached.
- Do not cache – if size exceeds – This prevents NetScaler caching objects that are too large and unwanted within the cache memory.
- Do not cache – if hits are less than – Do not cache objects if the request hits (user hits) against these objects/files are less than the number specified. This prevents using cache space for files that are not accessed often.
- Maximum memory usage limit – Sets a limit on the amount of NetScaler appliance memory that the content group can use.
- Prefetch – NetScaler will attempt to refresh cached objects that are about to go stale.
- Flash Cache – When multiple users request the same content, NetScaler will send one request to the backend server and that single response is used for all users.
You can flush and expire cached objects per content group basis on demand by navigating to Optimization -> Integrated Caching -> Content Groups.
Select a Content Group and select Action -> Invalidate.
Now select Flush or Expire and click OK.