This is an old revision of the document!


Why I see cache header on the homepage but not on all product pages?

I can see x-litespeed-cache: hit,litemage header on the homepage and catalog pages, but not on any product pages. Why?

You will need to investigate if xml default or other layout containing cacheable=“false”. If with default layout, it mostly like the whole sites won't be cached at all. If on other routes, then some certain route, such as all product pages won't be cached.

ssh to 'app' folder of your Magento2 installation.

grep -r cacheable * | grep xml | grep -v js | grep false
[root@server1 app]# grep -r cacheable * | grep xml | grep false | grep -v js | grep xml
code/Lof/RewardPoints/view/frontend/layout/rewardpoints_redeemcode_index.xml:                   <block class="Lof\RewardPoints\Block\Account\Dashboard\RedeemCode" name="rewards.redeemcode" template="account/dashboard/redeemcode.phtml" cacheable="false"/>
code/Lof/RewardPoints/view/frontend/layout/rewardpoints_transactions_index.xml:                 <block class="Lof\RewardPoints\Block\Account\Dashboard\Listing" after="customer_account_navigation_block" name="lrw.account.poitns" template="account/dashboard/listing.phtml" cacheable="false">
code/Lof/RewardPoints/view/frontend/layout/rewardpoints_settings_index.xml:                     <block class="Lof\RewardPoints\Block\Account\Dashboard\Notification" name="rewards.notification" template="account/dashboard/notification.phtml" cacheable="false"/>
code/Lof/RewardPoints/view/frontend/layout/rewardpoints_index_index.xml:                        <block class="Lof\RewardPoints\Block\Account\Dashboard\Summary" after="customer_account_navigation" name="lrw.account.summary" template="account/dashboard/summary.phtml" cacheable="false">
code/Lof/RewardPoints/view/frontend/layout/rewardpoints_index_index.xml:                        <block class="Lof\RewardPoints\Block\Account\Dashboard\Listing" after="rewards.account.summary" name="lrw.account.poitns" template="account/dashboard/listing.phtml" cacheable="false">
code/Lof/RewardPoints/view/frontend/layout/customer_account_index.xml:                  <block class="Lof\RewardPoints\Block\Account\Dashboard\Listing" before="customer_account_dashboard_info" name="lrw.account.poitns" template="account/dashboard/listing.phtml" cacheable="false">
code/Lof/RewardPointsBehavior/view/frontend/layout/catalog_product_view.xml:                    <block class="Lof\RewardPointsBehavior\Block\Buttons\Facebook\Like" name="lrw.fb.scripts" template="scripts.phtml" cacheable="false" />
code/Lof/RewardPointsRule/view/frontend/layout/catalog_product_view.xml:                        <block class="Lof\RewardPointsRule\Block\Product\View" after="product.info.review" cacheable="false" template="product/view/spendingrule.phtml"/>
code/Plumrocket/Newsletterpopup/view/frontend/layout/prnewsletterpopup_index_preview.xml:            <block class="Plumrocket\Newsletterpopup\Block\Preview\Template" name="prnewsletterpopup.preview" template="Plumrocket_Newsletterpopup::popup.phtml" cacheable="false">
code/Plumrocket/Newsletterpopup/view/frontend/layout/prnewsletterpopup_index_snapshot.xml:            <block class="Plumrocket\Newsletterpopup\Block\Preview\Template" name="prnewsletterpopup.preview" template="Plumrocket_Newsletterpopup::snapshot.phtml" cacheable="false">
code/Customweb/AuthipayCw/view/frontend/layout/authipaycw_customer_aliases.xml:         <block class="Customweb\AuthipayCw\Block\Customer\Aliases" name="authipaycw.customer.aliases" cacheable="false" />
code/Customweb/AuthipayCw/view/frontend/layout/authipaycw_customer_aliases.xml:            <block class="Magento\Customer\Block\Account\Dashboard" name="customer.account.link.back" template="account/link/back.phtml" cacheable="false"/>
code/Customweb/AuthipayCw/view/frontend/layout/authipaycw_externalcheckout_review.xml:                <block class="Magento\GiftMessage\Block\Cart\GiftOptions" name="checkout.cart.order.actions.gift_options" as="gift_options" template="Magento_GiftMessage::cart/gift_options.phtml" cacheable="false">
code/RealexPayments/HPP/view/frontend/layout/realexpayments_hpp_process_process.xml:        <block class="RealexPayments\HPP\Block\Process\Process" name="realexpayments-hpp-process-form" template="process/form.phtml" cacheable="false"/>
code/RealexPayments/HPP/view/frontend/layout/realexpayments_hpp_process_result.xml:        <block class="RealexPayments\HPP\Block\Process\Result" name="realexpayments-hpp-process-result" template="process/result.phtml" cacheable="false"/>
code/RealexPayments/HPP/view/frontend/layout/checkout_cart_index.xml:            <block class="RealexPayments\HPP\Block\Process\Result\Observe" name="realex.cart.observe" template="result/observe.phtml" cacheable="false"/>
code/RealexPayments/HPP/view/frontend/layout/realexpayments_hpp_cards_success.xml:            <block class="RealexPayments\HPP\Block\Cards\Success" name="customer.account.realexpayments.cards" template="cards/success.phtml" cacheable="false">
code/RealexPayments/HPP/view/frontend/layout/checkout_index_index.xml:            <block class="RealexPayments\HPP\Block\DeviceFinger\Tags" name="realex.checkout.devicefinger" template="devicefinger/tags.phtml" cacheable="false"/>
code/RealexPayments/HPP/view/frontend/layout/realexpayments_hpp_cards_redirect.xml:        <block class="RealexPayments\HPP\Block\Cards\Redirect" name="realexpayments-hpp-redirect-form" template="process/form.phtml" cacheable="false"/>
code/RealexPayments/HPP/view/frontend/layout/realexpayments_hpp_cards_view.xml:            <block class="RealexPayments\HPP\Block\Cards\View" name="customer.account.realexpayments.cards" template="cards/view.phtml" cacheable="false">
code/RealexPayments/HPP/view/frontend/layout/realexpayments_hpp_cards_result.xml:        <block class="RealexPayments\HPP\Block\Process\Result" name="realexpayments-hpp-process-result" template="process/result.phtml" cacheable="false"/>

You can analyze the code to determine that it won't be caused by RealexPayments or Plumrocket and it should be caused by Lof\RewardPoints. If you are familiar with Magento 2 code structure, any route from view/frontend/layout/catalog_product_view.xml of any module will be combine together and loaded to every product page.

For example:

under app folder:
[root@server1 app]# find . | grep 'layout/catalog_product_view.xml'

./code/Lof/RewardPoints/view/frontend/layout/catalog_product_view.xml

./code/Lof/RewardPointsBehavior/view/frontend/layout/catalog_product_view.xml
./code/Lof/RewardPointsRule/view/frontend/layout/catalog_product_view.xml
./code/WeltPixel/OwlCarouselSlider/view/frontend/layout/catalog_product_view.xml
./code/Vegvari/VovayatsyukAlsoviewedFix/view/frontend/layout/catalog_product_view.xml
./code/Ves/Blog/view/frontend/layout/catalog_product_view.xml-remove
./design/frontend/Meigee/fortress/Magento_Wishlist/layout/catalog_product_view.xml
./design/frontend/Meigee/fortress/Magento_Catalog/layout/catalog_product_view.xml-ORIG
./design/frontend/Meigee/fortress/Magento_Catalog/layout/catalog_product_view.xml

cd ../vendor/ root@server1 vendor]# find . | grep 'layout/catalog_product_view.xml'

./vovayatsyuk/magento2-alsoviewed/view/frontend/layout/catalog_product_view.xml
./magento/module-product-alert/view/frontend/layout/catalog_product_view.xml
./magento/magento2-base/dev/tests/integration/testsuite/Magento/Framework/View/Layout/_mergeFiles/layout/catalog_product_view.xml
./magento/module-checkout/view/frontend/layout/catalog_product_view.xml
./magento/module-google-optimizer/view/frontend/layout/catalog_product_view.xml
./magento/module-wishlist/view/frontend/layout/catalog_product_view.xml
./magento/theme-frontend-luma/Magento_Catalog/layout/catalog_product_view.xml
./magento/module-review/view/frontend/layout/catalog_product_view.xml
./magento/module-product-video/view/frontend/layout/catalog_product_view.xml
./magento/module-paypal/view/frontend/layout/catalog_product_view.xml
./magento/module-catalog-inventory/view/frontend/layout/catalog_product_view.xml
./magento/module-catalog/view/frontend/layout/catalog_product_view.xml
./magento/module-msrp/view/frontend/layout/catalog_product_view.xml

Any catalog_product_view.xml of the above will take effect for every page, excluding catalog_product_view.xml-ORIG and catalog_product_view.xml-remove since they have different names.

Hence we identified the following which caused the problem.

code/Lof/RewardPointsBehavior/view/frontend/layout/catalog_product_view.xml:                    <block class="Lof\RewardPointsBehavior\Block\Buttons\Facebook\Like" name="lrw.fb.scripts" template="scripts.phtml" cacheable="false" />

If no cache for the whole site, most likely you will find one of the module's default.xml cacheable=“false”.

code/Lof/RewardPointsBehavior/view/frontend/layout/default.xml: <block class="Lof\RewardPointsBehavior\Block\Buttons\Facebook\Like" name="lrw.fb.scripts" template="scripts.phtml" cacheable="false" />

How to make it cacheable then?

While you can simply back up the original XML and change cacheable=“false” to cacheable=“ true”. Please be aware that this solution may not work for your situation and may break some part of your store. Better engage our experienced Magento Developer for such troubleshooting.

  • Admin
  • Last modified: 2017/11/14 18:46
  • by Jackson Zhang