My cache stops caching or it enters secondary cache without adding to cart / logging in | Extendware

My cache stops caching or it enters secondary cache without adding to cart / logging in

This is because an AJAX request is calling a POST method. Change the AJAX request to GET or probably better just use HTTP Fox to determine the ajax request URL

Let’s say the url is example.com/module/controller/action?ajax See the directory structure of / module/controller /action? That is the module / controller / action and determines the page path that is used for the rule.

Next, create a rule telling the page cache to ignore the post request. In this case the rule would be this: <module-controller-action><on_post/></ module-controller-action>

Now, go to Page Cache -> Configure -> Advanced -> Page Rules and add this rule and save.

What this rule does is tell the page cache to ignore the post requests for that particular module/controller/action. 

You can also enable the output headers in Page Cache -> Configure -> Developer and look at the HTTP Headers for the AJAC request. The “X-Page-Path” header will be what you need to use for the rule (in this case namespace-module-action would be the page path).