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/06/04 19:30]
Jackson Zhang [Page is not cachable because of cacheable is set to false]
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 46: Line 67:
 You can verify this by switching the Magento 2 full page cache setting from LiteMage back to the built-in cache and testing the header again. Most likely you won't see a cache header there either. ​ You can verify this by switching the Magento 2 full page cache setting from LiteMage back to the built-in cache and testing the header again. Most likely you won't see a cache header there either. ​
  
-To find the plugin that is causing the conflict, navigate to the ''/​app/''​ and ''/​vendor/'' ​directory ​and execute the following command:+To find the plugin that is causing the conflict, navigate to the ''/​app/''​ and ''/​vendor/'' ​(user can install modules under either app or vendor, that depends on how user installs it. if using composer, it will be in vendor directries, so both /app/ and /vendor/ directories should be checked), ​and execute the following command:
   grep -r cacheable * | grep xml | grep false   grep -r cacheable * | grep xml | grep false
  
Line 61: Line 82:
  
 === What if ''​cacheable="​false"''​ appears somewhere other than ''​default.xml''?​ === === What if ''​cacheable="​false"''​ appears somewhere other than ''​default.xml''?​ ===
-''​default.xml''​ controls every page, but other template ​files may override it for different pages, such as your home page, catalog pages, or product pages. When you check the header, you will need to check all of them to find our which pages are cached, which pages are not.+''​default.xml''​ controls every page, but other layout ​files (.xml files) ​may override it for different pages, such as your home page, catalog pages, or product pages. When you check the header, you will need to check all of them to find out which pages are cached, which pages are not.
  
 For example, you may notice that the home page is not cached, but catalog and product pages are cached ok. In that case, you will need to look for the template which controls the home page, which is not ''​default.xml''​. For example, you may notice that the home page is not cached, but catalog and product pages are cached ok. In that case, you will need to look for the template which controls the home page, which is not ''​default.xml''​.
Line 71: Line 92:
 In this case, ''​cms_index_index.xml''​ is the one which controls the home page and you will need to modify the Smartwave theme'​s ''​cms_index_index.xml''​ In this case, ''​cms_index_index.xml''​ is the one which controls the home page and you will need to modify the Smartwave theme'​s ''​cms_index_index.xml''​
  
-==== Facebook ​plugin is one of the common plugins to cause the Magento store uncacheable ​====+==== Check the Facebook ​Plugin ​====
  
-Facebook plugin is one of the common plugins to cause the Magento store uncacheable. You can check /vendor/.+The Facebook plugin is one of the common plugins to cause the Magento store to be uncacheable. You can check the ''​/vendor/''​ or ''/​app/''​ directory.
  
-[root@Magento vendor]# grep -r '​cacheable="​false"'​ * | grep xml | grep default+  ​[root@Magento vendor]# grep -r '​cacheable="​false"'​ * | grep xml | grep default
  
   mgs/​social/​view/​frontend/​layout/​default.xml:​ <block class="​MGS\Social\Block\FacebookLikeBox"​ name="​social.facebook.page.plugin"​ after="​-"​ template="​MGS_Social::​fb-page-plugin.phtml"​ cacheable="​false"/>​   mgs/​social/​view/​frontend/​layout/​default.xml:​ <block class="​MGS\Social\Block\FacebookLikeBox"​ name="​social.facebook.page.plugin"​ after="​-"​ template="​MGS_Social::​fb-page-plugin.phtml"​ cacheable="​false"/>​
   mgs/​social/​view/​frontend/​layout/​default.xml:​ <block class="​Magento\Framework\View\Element\Template"​ name="​social.facebook.page.plugin.scripts"​ template="​MGS_Social::​scripts.phtml"​ cacheable="​false"/>​   mgs/​social/​view/​frontend/​layout/​default.xml:​ <block class="​Magento\Framework\View\Element\Template"​ name="​social.facebook.page.plugin.scripts"​ template="​MGS_Social::​scripts.phtml"​ cacheable="​false"/>​
 +
 +==== Verify that Magento'​s built-in cache is working ====
 +
 +LiteMage works similarly to Magento'​s built-in FPC cache. If you cannot see a LiteMage hit, you can verify if Magento'​s built-in FPC works. If FPC doesn'​t work either, then it is more likely that some plugins are making your Magento non-cachable,​ and it is not a LiteMage issue.
 +
 +To verify Magento built-in FPC cache:
 +
 +  * You will need to run in developer mode. You can modify the doc_root ''​.htaccess''​ by enabling(uncommenting) the following: <​code>​SetEnv MAGE_MODE developer</​code>​
 +  * In **Magento Admin > Stores > Configuration > Advanced > Full Page Cache > Caching Application**,​ select ''​Built-in Cache''​. {{ :​litespeed_wiki:​cache:​litemage2:​litemage-magento-built-in-cache.png?​700 |}} 
 +  * Navigate to **System ​ > Cache Management** and flush the Magento cache
 +  * Open the Chrome or Firefox development tool first, then visit your Store URL. You should see: <​code>​X-Magento-Cache-Control:​ max-age=86400,​ public, s-maxage=86400
 +  X-Magento-Cache-Debug:​ MISS</​code>​{{ :​litespeed_wiki:​cache:​litemage2:​litemage2-debug-fpc-cache-miss.png?​500 |}}
 +  * Visit the URL again, you should see: <​code>​X-Magento-Cache-Control:​ max-age=86400,​ public, s-maxage=86400
 +  X-Magento-Cache-Debug:​ HIT</​code>​{{ :​litespeed_wiki:​cache:​litemage2:​litemage2-debug-fpc-cache-hit.png?​500 |}}
 +
 +If Magento FPC is working fine, you should see the above. However, if you could not see ''​X-Magento-Cache-Debug:​ HIT'',​ then there is something wrong with your Magento extension.
 +
 +For example, if you always see ''​X-Magento-Cache-Debug:​ MISS''​ or ''​X-Magento-Cache-Control:​ max-age=0'',​ it means Magento'​s built-in cache cannot cache the page. If that's the case, LiteMage will have the same problem.
 +
 +{{ :​litespeed_wiki:​cache:​litemage2:​litemage2-debug-fpc-cache-wrong.png?​500 |}}
 +
 ==== See cache-control and litespeed-tag headers but no miss or hit ==== ==== See cache-control and litespeed-tag headers but no miss or hit ====
  
Line 101: 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.
    
 +===== 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. ​
 +
 +If you do a few rounds of testing, make sure to close the incognito window completely and open a new window for each round. This is required to simulate a brand new user.
 +
 +First visit:
 +{{ :​litespeed_wiki:​cache:​litemage2:​litemage2-cache-vary0.png?​800 |}}
 +
 +Second Visit:
 +{{ :​litespeed_wiki:​cache:​litemage2:​litemage2-cache-vary1.png?​800 |}}
 +
 +Third Visit:
 +{{ :​litespeed_wiki:​cache:​litemage2:​litemage2-cache-vary3.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.)
 +
 +{{ :​litespeed_wiki:​cache:​litemage2:​litemage2-cache-vary4.png?​400 |}}
 +
 +{{ :​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 a case, if you run a benchmark test through ''​ab''​ or ''​curl'',​ the result will be invalid, since the cache will never be hit: ''​curl -I http://​yourdomain.com/''​
 +
 +  HTTP/1.1 200 OK
 +  X-Powered-By:​ PHP/7.0.31
 +  Set-Cookie: store=he; expires=Thu,​ 15-Aug-2019 20:52:58 GMT; Max-Age=31536000;​ path=/; HttpOnly
 +  Set-Cookie: PHPSESSID=8d10hs84hmc881dl014s00ffm6;​ expires=Wed,​ 15-Aug-2018 21:52:58 GMT; Max-Age=3600;​ path=/; ​
 +  domain=carolinalemke.goomla.co.il;​ HttpOnly
 +  Set-Cookie: wp_customerId=deleted;​ expires=Thu,​ 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/; domain=carolinalemke.goomla.co.il
 +  Set-Cookie: wp_customerGroup=deleted;​ expires=Thu,​ 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/; ​
 +  domain=carolinalemke.goomla.co.il
 +  Set-Cookie: store_eu_ES=8d10hs84hmc881dl014s00ffm6;​ expires=Wed,​ 15-Aug-2018 21:52:58 GMT; Max-Age=3600;​ path=/; ​
 +  domain=carolinalemke.goomla.co.il;​ HttpOnly
 +  Set-Cookie: X-Magento-Vary=e3cb9ab3566a693edff3edf82caa39b1ed79e8ba;​ path=/; HttpOnly
 +  Set-Cookie: searchReport-log=0;​ path=/; HttpOnly
 +  Set-Cookie: _lscache_vary=9f858da3f6bbcc2862bc85d64d1b8ecb1bf2c076;​ path=/; HttpOnly
 +  X-Magento-Tags:​ store,​cms_b,​cms_b_footer_secure_payment,​cms_b_footer_develop_by,​cms_b_promotional_mailings,​cms_b_takanon,​cms_p_2
 +  X-Content-Type-Options:​ nosniff
 +  X-XSS-Protection:​ 1; mode=block
 +  X-Frame-Options:​ SAMEORIGIN
 +  Pragma: no-cache
 +  Cache-Control:​ max-age=0, must-revalidate,​ no-cache, no-store
 +  Expires: Tue, 15 Aug 2017 20:52:59 GMT
 +  Content-Type:​ text/html; charset=UTF-8
 +  Date: Wed, 15 Aug 2018 20:52:58 GMT
 +  Accept-Ranges:​ bytes
 +  Server: LiteSpeed
 +  X-UA-Compatible:​ IE=edge
 +  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