4

I am using varnish cache and also I've added AMP pages for mobile view. Now the thing is varnish is not detecting mobile and tab so I want to disable varnish for the homepage.

Everything was working fine when I added cacheable="false" in default.xml in theme folder but it will make whole website cacheable="false". I just want to disable for the homepage.

2

1 Answer 1

6

Try this,

Method 1:

Add the below code to homepage cms under

<referenceContainer name="content">
   <block cacheable="false"/>
</referenceContainer>

content -> pages -> select homepage -> under design tab -> Layout update xml

Method 2 :

If you want it via xml in the sense add the below code into

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
  <body>
    <referenceContainer name="content">
        <block cacheable="false"/>
    </referenceContainer>
</body>
</page>

cms_index_index.xml under layout folder.

NOTE : Disabling cache would certainly lower your site performance.

Hope this helps.

2
  • I applied method 1 and it worked. Will it disable cache for only home page? Apr 29, 2019 at 8:27
  • Yes, to whichever page u placed that code will be effective only on those pages Apr 29, 2019 at 8:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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