cancel
Showing results for 
Search instead for 
Did you mean: 

Module failing varnish check in Technical Review

Module failing varnish check in Technical Review

I am having a problem with a new module (upgraded from a Magento 1 module).  The technical review for the Module specifies that it fails on the Varnish check:Capture.PNG

 

Performing a quick search online indicates that this occurs if your view files (including blocks) have an invalid cache configuration.  However, I do not have any defined block or view files.  Any assistance would be appreciated.

 

Thanks

11 REPLIES 11

Re: Module failing varnish check in Technical Review

Hello,

Have you specified any where like cachable=false or lifetime value to 0.

If yes then remove it if you add for all pagees

Hope it will help you.

If help then give kudoes or mark as solution.

Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer

Re: Module failing varnish check in Technical Review

I do not have either of those specified in any of the module source files.

Re: Module failing varnish check in Technical Review

Hello,
In your content some part coming dynamic like customer name or something else.

Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer

Re: Module failing varnish check in Technical Review

We capture the customer from session; e.g. -

$customerName = trim($this->session->getCustomer()->getName());

Everything else is loaded via config or request objects.

Re: Module failing varnish check in Technical Review

Hello @Freightquote

 

Seems like that is an issue, in varnish page coming from the cache so every time it will show some info.

 

So you need to add cachable false, or you need to get customer name using section method or ajax.

 

Hope it will help you.

 

If help you then mark as solution.


Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer

Re: Module failing varnish check in Technical Review

I am not using a block element so I cannot add cachable false.  The module itself extends AbstractInterface and implements CarrierInterface.

 

Inside the main body of this code is where I have my session calls.  I have tried to use ObjectManager to get session instance data but that also fails the varnish tests; e.g. -

/* Cart Items */
$objectManager = ObjectManager::getInstance();
$session = $objectManager->get('\Magento\Checkout\Model\Session');
$quote = $session->getQuote();
$items = $quote->getAllItems();

/* Customer */
$objectManager = ObjectManager::getInstance();
$session = $objectManager->get('\Magento\Customer\Model\Session');
$customer = $session->getCustomer();

 

Re: Module failing varnish check in Technical Review

Hello @Freightquote

 

This is not the right way to call object manager into phtml.

 

 


Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer

Re: Module failing varnish check in Technical Review

This is called from my php source.  I do not have any phtml files.

Re: Module failing varnish check in Technical Review

Any other ideas???