Differences

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

Link to this comparison view

Both sides previous revision Previous revision
litespeed_wiki:cache:drop_query_string [2018/07/26 13:29]
Jackson Zhang
litespeed_wiki:cache:drop_query_string [2018/07/26 14:13] (current)
Lisa Clarke Proofreading and Reorganizing
Line 1: Line 1:
-====== ​How to drop Query Strings ​when using LSCache? ​======+====== ​Dropping ​Query Strings ​via Cache Rules ======
  
-For each query string that is attached to a URL, a separate copy of the page is cached. In many cases this is intentional,​ desired behavior. However, when you have "​junk"​ query string parameters that don't change the content of the page, it's redundant to cache separate copies. ​In an effort to make some requests more cache friendly, LiteSpeed Enterprise v5.2.3+ ​added a feature ​to drop certain query string parameters. ​+In an effort to make some requests more cache friendly, LiteSpeed Enterprise v5.2.3+ ​may be configured ​to drop certain query string parameters.
  
-There are two ways to modify/​drop ​query strings: one is to use Apache like configuration directive ''​CacheKeyModify ...''​and the other one is to use the rewrite ruleswhich is more flexible and preferred way.+===== Why is This Helpful? ===== 
 +For each query string that is attached ​to a URL, a separate copy of the page is cachedIn many cases this is intentional,​ desired behaviorHoweverwhen you have "​junk"​ query string parameters that don't change ​the content of the pageit's redundant to cache separate copies.
  
-===== Method 1: Using Apache like configuration directive ''​CacheKeyModify ...''​ ===== +Junk query strings ​include ​UTM codes and Google AdWords auto tags, among others.
-The Apache-style configuration directive is ''​CacheKeyModify ...'',​ and its purpose is to modify the query string attached to a URL. +
- +
-The directive can be added to the Apache server, vhost and .htaccess levels.  +
- +
-Upper level configurations are inherited by lower levels. If a lower level adds more rules, they are in addition to those of the upper level.(This addition feature may not be fully implemented yet, but it //will// be fully implemented.) If a lower level doesn'​t want to use the upper level'​s configuration,​ the "​clear"​ parameter should be used before adding the new rules. +
- +
-The ''​CacheKeyModify''​ directive can be used multiple times. Adding multiple modifications in one line is not supported. Multiple lines are combined. +
- +
-This function is suitable for users whose site brings junk query strings, e.g. UTM code, Google AdWords auto tags, etc, and gets too many different URLs which //should// be stored and served from the same cache page but in practice are not.+
  
 ==== What is a UTM code? ==== ==== What is a UTM code? ====
Line 24: Line 16:
 Google AdWords can be configured to add tracking parameters to your URLs in order to pass information about the click. Similar to UTM codes, this kind of tag has no bearing on the content of the page, and therefore may be ignored when caching. These tags appear in the format ''&​glcid=XXXXXXX''​. Google AdWords can be configured to add tracking parameters to your URLs in order to pass information about the click. Similar to UTM codes, this kind of tag has no bearing on the content of the page, and therefore may be ignored when caching. These tags appear in the format ''&​glcid=XXXXXXX''​.
  
-==== Examples ​====+===== How to Drop Query Strings ===== 
 + 
 +There are two ways to modify/​​drop ​query strings: one is to use the Apache-like configuration directive ''​​CacheKeyModify ...''​​,​ and the other one is to use ''​E=cache-key-mod:''​ in rewrite rules. The second method is more flexible and is the preferred way. 
 + 
 +Both methods serve the same purpose: to modify the query string attached to a URL.  
 + 
 +==== Method 1: Apache-style CacheKeyModify ==== 
 + 
 +The directive can be added to the Apache server, vhost and .htaccess levels.  
 + 
 +Upper level configurations are inherited by lower levels. If a lower level adds more rules, they are in addition to those of the upper level.(This addition feature may not be fully implemented yet, but it //will// be fully implemented.) If a lower level doesn'​t want to use the upper level'​s configuration,​ the "​clear"​ parameter should be used before adding the new rules. 
 + 
 +The ''​CacheKeyModify''​ directive can be used multiple times. Adding multiple modifications in one line is not supported. Multiple lines are combined. 
 + 
 +This function is suitable for users whose site brings junk query strings, e.g. UTM code, Google AdWords auto tags, etc, and gets too many different URLs which //should// be stored and served from the same cache page but in practice are not. 
 + 
 +=== Examples ​===
  
   * ''​CacheKeyModify -qs:​utm*''​ drops all query strings where the name part starts with "​utm"​   * ''​CacheKeyModify -qs:​utm*''​ drops all query strings where the name part starts with "​utm"​
Line 31: Line 39:
   * ''​CacheKeyModify clear''​ discards all previous configurations.   * ''​CacheKeyModify clear''​ discards all previous configurations.
  
-==== How to Enable the LSWS Drop Query String Feature ​on cPanel ​using ''​CacheKeyModify ...''?​ ====+=== CacheKeyModify ​on cPanel ===
  
 As long as the LSWS version is 5.2.3 or above, this feature is enabled by default and does not need any further configuration in the LSWS WebAdmin GUI or in Apache configurations. You may wish to override the default settings at the server level, virtual-host level or even the ''​.htaccess''​ level. As long as the LSWS version is 5.2.3 or above, this feature is enabled by default and does not need any further configuration in the LSWS WebAdmin GUI or in Apache configurations. You may wish to override the default settings at the server level, virtual-host level or even the ''​.htaccess''​ level.
  
-==== Examples for a WHM/cpanel EA4 environment ​====+== Examples for a WHM/cpanel EA4 environment ==
  
 After you run the following, the drop query string feature will be automatically enabled globally (replace 5.2.3 with the appropriate version): After you run the following, the drop query string feature will be automatically enabled globally (replace 5.2.3 with the appropriate version):
Line 76: Line 84:
 * The feature to add rule sets may not be fully implemented on v5.2.3, but //will// be fully implemented in the next release. * The feature to add rule sets may not be fully implemented on v5.2.3, but //will// be fully implemented in the next release.
  
-===== Method 2: How to Modify LSCache Query Strings with Rewrite Rules ===== +==== Method 2: Rewrite Rules ==== 
-Other than ''​CacheKeyModify ​...'', ​We can also use rewrite rules to modify/drop query stings. This method supports multiple commands combined and gives you more flexibility.+As an alternative to ''​CacheKeyModify'', ​we can also use rewrite rules. This method supports multiple commands combinedand gives you more flexibility.
  
 For this example, we remove ''​utm_source''​ with an exact match, and ''​utm_medium''​ with a prefix match. For this example, we remove ''​utm_source''​ with an exact match, and ''​utm_medium''​ with a prefix match.
Line 94: Line 102:
 </​code>​ </​code>​
  
-===== How to Verify ​it's Working ​=====+===== How to Verify ​Query Strings Have Been Dropped ​=====
 ==== Prepare a URL with a Junk Query String==== ==== Prepare a URL with a Junk Query String====
 Assume we have a public WordPress site with the domain ''​testquerystring.com''​ and LSCache enabled. Use [[https://​ga-dev-tools.appspot.com/​campaign-url-builder/​ | Campaign URL Builder]] or other UTM plugin to generate a URL, which will look like this: Assume we have a public WordPress site with the domain ''​testquerystring.com''​ and LSCache enabled. Use [[https://​ga-dev-tools.appspot.com/​campaign-url-builder/​ | Campaign URL Builder]] or other UTM plugin to generate a URL, which will look like this:
  • Admin
  • Last modified: 2018/07/26 14:13
  • by Lisa Clarke