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
litespeed_wiki:cache:common:logged-in-cookie-conflicts [2017/02/22 16:25]
Kevin Fwu
litespeed_wiki:cache:common:logged-in-cookie-conflicts [2020/11/14 15:25] (current)
Lisa Clarke Redirect to new Documentation Site
Line 1: Line 1:
-====== Managing Multiple LSCache Plugins in a single Virtual Host ====== +~~REDIRECT>https://docs.litespeedtech.com/lscache/troubleshoot/~~
- +
-===== Do I need to do anything? ===== +
-This wiki entry is intended for people who have multiple [[litespeed_wiki:​cache#​litespeed_cache_plugins_by_application|LSCache plugins]] in the same document root. This includes two of the same web application (e.g. two WordPress installs in the same document root). For these situations, some extra steps may be required to correctly cache the web applications. If this does not describe the situation, then there is likely no extra steps involved. +
- +
-===== Modifying .htaccess Manually ===== +
- +
-When using multiple web applications in a single domain (two of the same application counts as two), there may be some issues where a page is served from cache when it shouldn'​t be. This is by multiple LSCache plugins all using the same default _lscache_vary cookie to check logged-in status. +
- +
-A good example of this is a domain with WordPress serving www.example.com/​ and XenForo serving www.example.com/​forums/​. If a user logs into WordPress, the _lscache_vary cookie will be set to indicate that they are logged in. This same user then visits XenForo as a non-logged in user and hits the backend. Since we are a non-logged in user, LSCache caches the request with the logged in _lscache_vary cookie still set. This can then cause future users logged in to XenForo to get a "cache hit" on this page and be served the non-logged in version of the page. +
- +
-To prevent this, add the following rewrite rule to the .htaccess file under the application’s root directory, after RewriteBase and before all rules using the [L] flag. +
- +
-<code> +
-RewriteRule .? - [E=Cache-Vary:_my_custom_vary] +
-</code> +
- +
-“_my_custom_vary” is the cookie name that will now be used by that application. A unique name should be used for each application under the same domain. +
- +
-For example, in the above scenario, the WordPress .htaccess file may have something like: +
- +
-<​code>​ +
-RewriteRule .? - [E=Cache-Vary:​_my_vary_EXAMPLE_wordpress] +
-</code> +
- +
-And the XenForo ​.htaccess file might have: +
-<​code>​ +
-RewriteRule ​.? - [E=Cache-Vary:​_my_vary_EXAMPLE_xenforo] +
-</code> +
- +
-This is used to differentiate users logged into WordPress and users logged into XenForo, so the pages that should be served from cache will be correctly served from cache. +
- +
-===== Modifying within a plugin ===== +
- +
-It is possible to have multiple cache plugins in a single virtual host. However, to avoid any conflicts between them, it is recommended to set a few configuration options available in the plugins. +
- +
-==== Tweaking the Login Cookies ==== +
-By default, the cache will use ''​_lscache_vary''​ as the login cookie in all the web applications. This causes an issue, because a user could be logged in to one web application and not the other. Once the user visits the non-logged in application,​ a cache entry will be created for the page with the login cookie. Since both applications recognize the same cookie, logged in users visiting that page will be served from cache. This issue can be resolved by modifying at least one of the web applications. +
- +
-=== In WordPress === +
-The login cookie can be modified in the WP-Admin panel. The relevant option is in LiteSpeed Cache ->  Settings -> Advanced, as depicted below: +
-{{ :​litespeed_wiki:​cache:​wordpress_login_cookie.png?​direct&​700 |}} +
- +
-=== In XenForo === +
-The XenForo plugin will not modify the rewrite rules directly. The setting in XenForo is in the admin panel under Home -> LiteSpeed Cache -> Settings, as depicted below: +
- +
-{{ :​litespeed_wiki:​cache:​xenforo_login_cookie.png?​direct&​700 |}} +
- +
-After saving, a notification will appear. The notification will instruct you further on what to add to the rewrite rules, like so: +
- +
-{{ :​litespeed_wiki:​cache:​xenforo_rules.png?​direct&​700 |}} +
- +
-After adding the rules, it can be verified in the LiteSpeed Cache Management screen: +
- +
-{{ :​litespeed_wiki:​cache:​xenforo_verify.png?​direct&​700 |}} +
- +
-If the changes are correct, it will output the following:​ +
- +
-{{ :​litespeed_wiki:​cache:​xenforo_verified.png?​direct&​700 |}} +
- +
-==== Cache Tag Prefix ==== +
-The Cache Tag Prefix should be used in situations where multiple of the same web application is installed in the same virtual host (e.g. a WordPress in /public_html/shop/ and another WordPress in /​public_html/​). Using different cache tag prefixes will prevent possibly purging too many pages. +
- +
-=== In WordPress === +
-The cache tag prefix can be modified in the WP-Admin panel. The relevant option is in LiteSpeed Cache ->  Settings -> Advanced, as depicted below: +
- +
-{{ :​litespeed_wiki:​cache:​wordpress_cache_tag.png?​direct&​700 |}} +
- +
-=== In XenForo === +
-The cache tag prefix can be modified in the Xenforo Admin. The setting in XenForo is in the admin panel under Home -> LiteSpeed Cache -> Settings, as depicted below: +
- +
-{{ :​litespeed_wiki:​cache:​xenforo_cache_tag.png?​direct&​700 |}} +
  • Admin
  • Last modified: 2017/02/22 16:25
  • by Kevin Fwu