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.


Try this,

Method 1:

Add the below code to homepage cms under

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

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">
  <referenceContainer name="content">
      <block cacheable="false"/>

cms_index_index.xml under layout folder.

NOTE : Disabling cache would certainly lower your site performance.

Hope this helps.

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

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.