0

Please help me, I want to know exactly how the Invalidate private content works? the solution to invalidate private content? example: when I add to cart in Magento 2, how to identify change data and update changes in Full Page Cache. solution, not code. enter image description here

1

I believe you want to understand how to add a section source map configuration in a custom module.

Magento\Customer\CustomerData\SectionPool

once this configuration is defined, you can specify what event triggers the content to be revalidated in a di.xml file

The below for instance, clears the section labelled 'login_flag' when a

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Customer:etc/sections.xsd">
    <action name="checkout/cart/add">
        <section name="login_flag"/>
    </action>
</config>
| improve this answer | |
  • thanks for your answer , But what I want is a better understanding of this : " Since private content is specific to individual users, it is reasonable to handle it on the client (i.e., web browser). Use our customer-data JS library to store private data in local storage, invalidate private data using customizable rules, and synchronize data with the backend. This example displays a customer’s name on a cacheable page. " in devdocs.magento.com/guides/v2.3/extension-dev-guide/cache/… – Tiến Nguyễn Tất May 13 at 9:56
  • yes, customer data is what you want to understand. If the data you want to access and interact with is within Magento core data, then you are right, using javascript customerData dependency is perfect. However, if the data you need is in your own module, then you need your own section. I have a module showing how to create a simple private content section at bitbucket.org/magstaging/punchhole/src/master – Herve Tribouilloy May 13 at 10:04
  • thanks for your answer, – Tiến Nguyễn Tất May 13 at 10:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.