How do I include a dynamic block in the product page with full page caching turned on?

前端 未结 4 1212
闹比i
闹比i 2020-12-12 09:32

We would like to add a dynamic block to the product page. The problem is that the product page has full page caching (and we cannot turn that off due to speed issues). We

4条回答
  •  忘掉有多难
    2020-12-12 10:15

    In general, there are two approaches you can use if you want to personalise a page which is intended to be stored in a full page cache.

    1. If your reverse proxy supports it, you can use ESI (Edge Side Includes) and mark up your template appropriately. ESI allows you to insert a marker in your generated HTML where the personalised content should go, then your proxy will request just the personalised content from your app server's appropriate controller path when required. If you're using Varnish, ESI is available to use. The Lightspeed extension for Magento has a feature called "Hole Punching" which does a similar thing.
    2. If ESI or Hole Punching isn't available to you, then the other option is to allow the main page to be cached in your full page cache, and use a bit of javascript to make a separate Ajax request and fetch the information you need.

提交回复
热议问题