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
Last revision Both sides next revision
litespeed_wiki:cache:litemage2:troubleshooting [2018/08/15 20:59]
Jackson Zhang [Is there any _lscache_very cookie problem causing new user always cache miss?]
litespeed_wiki:cache:litemage2:troubleshooting [2019/11/12 21:14]
Jackson Zhang
Line 41: Line 41:
  
 {{ :​litespeed_wiki:​cache:​litemage2:​litemage-pagecache-enable.png?​800 |}} {{ :​litespeed_wiki:​cache:​litemage2:​litemage-pagecache-enable.png?​800 |}}
 +
 +==== EnableDebug "Yes and set X-LiteMage-Debug response headers"​ ====
 +LiteMage 2.1.0 and above includes the **X-LiteMage-Debug response headers** feature, designed to make troubleshooting easier. ​
 +
 +When you try everything in the wiki but you still are not seeing an ''​X-LiteSpeed-Cache:​ hit,​litemage''​ header, enable this debug feature to collect more information.
 +
 +Navigate to **Magento Admin > Stores > Advanced > LiteMage Cache > Developer Settings**, and set **Enable Debug** to ''​Yes and set X-LiteMage-Debug response headers''​. You can also add your IP to to the **Log Debug Messages Only for Listed IPs** field to show the debug header to your IP only.  ​
 +{{ :​litespeed_wiki:​cache:​litemage2:​litemage2-enable-debug-response-headers1.png?​800 |}}
 +
 +Once enabled, you can browse your site, and use the browser'​s developer tool to check the header:
 +{{ :​litespeed_wiki:​cache:​litemage2:​litemage2-enable-debug-response-headers-2.png?​800 |}}
 +
 +In this case, the **Headers** show:
 +  x-litemage-debug-cc: ​
 +  x-litemage-debug-info:​ Layout has uncacheable blocks mgs_gdpr_login_header,​ wishlist-link-header,​ wishlist_header,​ wishlist_header, ​
 +  captcha-header
 +  x-litemage-debug-tag: ​
 +  x-litemage-debug-vary:​
 +  ​
 +The info ''​Layout has uncacheable blocks mgs_gdpr_login_header,​ wishlist-link-header,​ wishlist_header,​ wishlist_header, ​
 +  captcha-header''​ tells you that there are five blocks which are causing the page to be uncacheable. If you want to cache the page, you will either need to disable to blocks, or modfiy the template to make them ''​cacheable''​.
 ==== Page is not cachable because of "​cacheable"​ is set to "​false"​==== ==== Page is not cachable because of "​cacheable"​ is set to "​false"​====
 If you followed every step in the installation wiki and still do not see the ''​X-LiteSpeed-Cache:​ hit,​litemage''​ header for that page/for all pages, it is likely that the page is non-cacheable due to a setting from another plugin. If you followed every step in the installation wiki and still do not see the ''​X-LiteSpeed-Cache:​ hit,​litemage''​ header for that page/for all pages, it is likely that the page is non-cacheable due to a setting from another plugin.
Line 122: Line 143:
 To fix the problem, remove the ''/​home/​$USER/​lscache''​ folder completely and restart the web server. The cache root folder (normally ''/​home/​$USER/​lscache''​) will be created with correct ownership and permissions automatically during the restart. After restart, you should see the ''​x-litespeed-cache:​hit,​litemage''​ header. To fix the problem, remove the ''/​home/​$USER/​lscache''​ folder completely and restart the web server. The cache root folder (normally ''/​home/​$USER/​lscache''​) will be created with correct ownership and permissions automatically during the restart. After restart, you should see the ''​x-litespeed-cache:​hit,​litemage''​ header.
    
-===== Is there any _lscache_very cookie problem causing new user always cache miss? =====+===== LSCache Vary Cookie Problem Causing Cache Miss ===== 
 +==== Diagnose the Issue ==== 
 +With LiteMage2 enabled, open a brand new Chrome Incognito window to test the site and check the headers. You may see a cache vary cookie being set. This is a signal that the first visit from a new user sets a cache vary cookie but is not cached. On the second visit you might see cache miss, and a cache hit on the third. ​
  
-When LiteMage2 enableduse chrome ​to check the header, you will see cache miss first, then cache hit, which is quite normal.+If you do a few rounds of testingmake sure to close the incognito window completely and open a new window for each round. This is required to simulate a brand new user.
  
-{{ :​litespeed_wiki:​cache:​litemage2:​litemage2-cache-very1.png?800 |}}+First visit: 
 +{{ :​litespeed_wiki:​cache:​litemage2:​litemage2-cache-vary0.png?800 |}}
  
-{{ :​litespeed_wiki:​cache:​litemage2:​litemage2-cache-very3.png?400 |}}+Second Visit: 
 +{{ :​litespeed_wiki:​cache:​litemage2:​litemage2-cache-vary1.png?800 |}}
  
-However, when you use another browser firefox ( or alternatively using Chrome Incognito windows) to simulate different user and check the same homepage, you will suppose to see cache hit for the first visit, but actually not for this case and only see cache hit on the second visit. What happens? +Third Visit: 
-{{ :​litespeed_wiki:​cache:​litemage2:​litemage2-cache-very4.png?400 |}}+{{ :​litespeed_wiki:​cache:​litemage2:​litemage2-cache-vary3.png?400 |}}
  
-{{ :​litespeed_wiki:​cache:​litemage2:​litemage2-cache-very5.png?400 |}}+Next, you can use another browser such as Firefox to simulate a different user and check the same page. On the first visit, you will see the cache vary cookie being set. The second visit, since the page has already been cached, you will see a cache hit. (If the page has not yet been cached, you will see cache miss on the second visit and cache hit on the third.)
  
-There is a _lscache_very set, which causes all new users first visit will be always cache miss.  +{{ :​litespeed_wiki:​cache:​litemage2:​litemage2-cache-vary4.png?400 |}}
-{{ :​litespeed_wiki:​cache:​litemage2:​litemage2-cache-very2.png?300 |}}+
  
-For such case, if you run some benchmark test through ab or curl, the result will be invalid since the cache will never be hit. +{{ :​litespeed_wiki:​cache:​litemage2:​litemage2-cache-vary5.png?​400 |}} 
 + 
 +There is an ''​_lscache_vary''​ set, which causes all new users' first visit to always be a cache miss.  
 +{{ :​litespeed_wiki:​cache:​litemage2:​litemage2-cache-vary2.png?​500 |}} 
 + 
 +For such case, if you run benchmark test through ​''​ab'' ​or ''​curl''​, the result will be invalidsince the cache will never be hit: ''​curl -I http://​yourdomain.com/''​
  
- curl -I http://​yourdomain.com/​ 
   HTTP/1.1 200 OK   HTTP/1.1 200 OK
   X-Powered-By:​ PHP/7.0.31   X-Powered-By:​ PHP/7.0.31
Line 168: Line 196:
   Connection: Keep-Alive   Connection: Keep-Alive
  
 +==== Fix the Problem ====
 +To fix the problem, you will need to locate the plugin or toolbar that is causing the LiteMage cache vary.
 +
 +In this example, we have found an accessibility plugin on the homepage which causes such a problem. You may have other plugins such as a currency switcher plugin, a language plugin or a geolocation plugin, which does the same.
 +
 +{{ :​litespeed_wiki:​cache:​litemage2:​litemage2-cache-vary6.png?​400 |}}
 +
 +The accessibility plugin can be further expanded to the following if you click it:
 +
 +{{ :​litespeed_wiki:​cache:​litemage2:​litemage2-cache-vary7.png?​400 |}}
  
 +You will need to disable this type of plugin if you want a new user to hit the cache on their first visit. ​
  
 +If you still want to use the plugin, it is not going to be as bad as you may think. This issue only impacts a user's first visit to one page (not the first visit to //each// page). For the rest of the user's visits, all pages can be served from cache, presuming they have already been cached by previous visitors. ​
 ===== How to setup cache warm up for Magento 2 using LiteMage 2 ===== ===== How to setup cache warm up for Magento 2 using LiteMage 2 =====
 Magento 2 warm up is not available yet. You could set public TTL to a longer time at this stage instead, for example 24 hrs, if applicable. Magento 2 warm up is not available yet. You could set public TTL to a longer time at this stage instead, for example 24 hrs, if applicable.
  • Admin
  • Last modified: 2020/07/08 19:33
  • by Lisa Clarke