Full Page Cache Issues in Magento EE 1.12
Dear Steve,
Thank you for reaching out regarding your Magento FPC issue on the custom options module. I understand that you’re facing challenges with cookie data being cached by the full-page cache system, despite using hole punching techniques.
Understanding the Cookie Issue
Your current setup involves saving selected product options in cookies so that they can be pre-populated during subsequent visits to the same product page. However, when Magento’s FPC is enabled, it caches the entire HTML response of a page, including any cookie values present at the time of caching.
The issue lies in how Magento handles and interprets these cookie values. Even though you’re using hole punching techniques (which should theoretically exclude certain parts of the page from being cached), it seems that the FPC is still capturing and preserving the cookie data.
Alternative Solutions to Counter the Issue
1. Exclude Specific Cookies from Cache
Instead of relying on hole punching for the entire container, you can attempt to exclude specific cookies from being cached. Magento allows you to configure which cookies should be ignored by the FPC.
To do this, you’ll need to modify the app/code/core/Enterprise/PageCache/etc/config.xml file and add a new <ignore_cookie> node under the <page_cache> section:
<ignore_cookie>
<name>myprescription</name>
</ignore_cookie>
Replace myprescription with the name of your cookie. This tells Magento not to include this specific cookie in the cached page.
2. Use a Custom Cookie Handler
Another approach is to create a custom cookie handler that avoids being detected by the FPC. You can extend the core Mage_Core_Model_Cookie class and override the __construct() method to prevent the cookie from being sent with each request.
Here’s an example of how you might implement this:
class MageWorx_Customoptions_Model_Cookie extends Mage_Core_Model_Cookie
{
protected $_ignoreByPageCache = true;
public function __construct($name, $value = null)
{
parent::__construct($name, $value);
}
}
This custom cookie model can then be used in place of the standard Mage::getModel('core/cookie') calls.
Modifying Cache and Pagecache XML Files
Since you mentioned that this is a custom module, you have control over how it interacts with Magento’s cache system. You can modify the module/etc/cache.xml file to define which blocks or containers should be excluded from caching:
<cache>
<block type="mycustomoptions/container_cachetest" output="toHtml"/>
</cache>
Or you can update the pagecache/cache.xml file to specify which identifiers should not be cached.
Remember, modifying core files directly is typically discouraged in Magento development. It’s usually recommended to work with overrides or custom extensions instead of altering the base files themselves.
Conclusion and Next Steps
In summary, the main challenge is that Magento’s FPC is capturing cookie values even when hole punching techniques are applied. To resolve this:
- Try excluding specific cookies from being cached using the
config.xmlmodification I mentioned earlier. - Consider implementing a custom cookie handler to prevent detection by the FPC.
- Ensure your module’s cache configuration is correctly set up to exclude relevant blocks or identifiers.
I recommend testing each of these solutions in a development environment before deploying them to your live site. Please let me know if you need any further assistance or clarification on this issue.
Feel free to check out our blog at https://laravelcompany.com/blog for more Magento e-commerce tips and tricks!
Best regards,
[Your Name] Laravel Company