Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
litespeed_wiki:cache:developer_guide:cache-vary [2017/02/28 15:24]
Kevin Fwu [Vary Types]
litespeed_wiki:cache:developer_guide:cache-vary [2017/02/28 21:45]
Kevin Fwu [Vary Cookie]
Line 2: Line 2:
  
 The Cache Vary is an important concept for caching. For simplicity'​s sake, the idea behind cache varies is that they allow the cache to save multiple versions of the same URL. The Cache Vary is an important concept for caching. For simplicity'​s sake, the idea behind cache varies is that they allow the cache to save multiple versions of the same URL.
 +
 +Using the public cache key as an example, KEY = Host + URI + Query String + VARY
 +
 +This article describes the VARY portion of the cache key.
  
 ===== Examples of reasons to use cache vary: ===== ===== Examples of reasons to use cache vary: =====
Line 10: Line 14:
  
 There are two types of cache varies, vary cookie and vary value. Both are used when determining which version to return. Setting a Vary Cookie will notify the server about which cookies to keep an eye on. This will not actually set a cookie. Setting a Vary Value will set an environment value strictly for the use of varying the request. There are two types of cache varies, vary cookie and vary value. Both are used when determining which version to return. Setting a Vary Cookie will notify the server about which cookies to keep an eye on. This will not actually set a cookie. Setting a Vary Value will set an environment value strictly for the use of varying the request.
 +
 +Using the earlier cache key equation, VARY can be expanded to:
 +
 +VARY = VARY_COOKIE + VARY_VALUE
  
 ==== Vary Cookie ==== ==== Vary Cookie ====
Line 17: Line 25:
  
   * Request A has NO cookies.   * Request A has NO cookies.
 +    * VARY = ''​
   * Request B has the cookie my_cookie = Alabama   * Request B has the cookie my_cookie = Alabama
 +    * VARY = '​my_cookie=Alabama'​
   * Request C has the cookie my_cookie = California   * Request C has the cookie my_cookie = California
 +    * VARY = '​my_cookie=California'​
   * Request D has the cookie my_cookie = Alabama   * Request D has the cookie my_cookie = Alabama
 +    * VARY = '​my_cookie=Alabama'​
  
 For this example, Requests B and D will get the same cached version (or another way to see it: request B can generate the cache entry for request D). Their cache entry will differ from requests A and C, both of which have a unique cache entry. So there are 3 total cache entries. For this example, Requests B and D will get the same cached version (or another way to see it: request B can generate the cache entry for request D). Their cache entry will differ from requests A and C, both of which have a unique cache entry. So there are 3 total cache entries.
Line 36: Line 48:
 ==== Rewrite Rules ==== ==== Rewrite Rules ====
  
-Rewrite Rules can be used to vary the request when it comes in.+Rewrite Rules can be used to vary the request when it comes in. Varies set by Rewrite Rules will be forwarded to the web application via environment variables. In PHP, these are ''​$_SERVER['​LSCACHE_VARY_COOKIE'​]''​ and ''​$_SERVER['​LSCACHE_VARY_VALUE'​]''​ respectively. For cookies, it will be the list of cookie names that the server checked. For value, it will be the value used. This may be empty if no vary values are set.
  
 === Vary Cookie === === Vary Cookie ===
Line 45: Line 57:
 This example rewrite rule will instruct the server to check for the "​my_cookie"​ cookie NAME and if it exists, vary on it. This example rewrite rule will instruct the server to check for the "​my_cookie"​ cookie NAME and if it exists, vary on it.
  
-As of LSWS version 5.1.x and OLS 1.4.x, it is possible to add more vary cookies to the rewrite rule. +As of LSWS version 5.1.x and OLS 1.4.x, it is possible to add multiple ​vary cookies to the rewrite rule. 
  
 Example: Example:
  • Admin
  • Last modified: 2020/07/31 19:35
  • by Lisa Clarke