Magento Forum

   
Design Exception not working with Full Page Cache in Enterprise 1.11
 
PurpleLab
Jr. Member
 
Total Posts:  2
Joined:  2008-09-29
 

Hi All,

Have a problem here. We are just preparing the mobile version of the website, so decided to use design exceptions to recognize user agents and server proper content for mobile users.

The issue is that we want to set the new mobile Theme inside the package that we are using for whole website - to make sure the files that are not in mobile theme fall back to our package default theme. Just tested that configuration with Full Page Cache enabled and it caches the mobile page and serves it to desktop users too!

Seems that design exceptions only work with FPC when defined on package level, but we would like to avoid creating new package as this would mean we will have to duplicate some part of code from our main package.

Did anyone managed to use design exception to serve mobile theme successfully with Full Page Cache enabled. How?

Thanks for help
Gosia

 
Magento Community Magento Community
Magento Community
Magento Community
 
a1anm
Guru
 
Total Posts:  318
Joined:  2009-10-08
 

Hi,

Did you solve this?  Having the same problem with a different caching extension.

Thanks!!

 
Magento Community Magento Community
Magento Community
Magento Community
 
fvadev
Jr. Member
 
Total Posts:  1
Joined:  2011-08-24
 
gosia - 04 October 2012 05:46 AM

Hi All,

Have a problem here. We are just preparing the mobile version of the website, so decided to use design exceptions to recognize user agents and server proper content for mobile users.

The issue is that we want to set the new mobile Theme inside the package that we are using for whole website - to make sure the files that are not in mobile theme fall back to our package default theme. Just tested that configuration with Full Page Cache enabled and it caches the mobile page and serves it to desktop users too!

Seems that design exceptions only work with FPC when defined on package level, but we would like to avoid creating new package as this would mean we will have to duplicate some part of code from our main package.

Did anyone managed to use design exception to serve mobile theme successfully with Full Page Cache enabled. How?

Thanks for help
Gosia

We have solved this issue by adding HTTP user agent to the Full page cache id:

1. copy app/code/core/Enterprise/PageCache/Model/Processor.php to app/code/local/Enterprise/PageCache/Model/Processor.php
2. edit app/code/local/Enterprise/PageCache/Model/Processor.php - find method _createRequestIds() and after

if ($designPackage{
                $uri 
.= '_' $designPackage;
            
}
add the following:
/* here we add user agent for mobile theme to the cache id */
            if (isset($_SERVER['HTTP_USER_AGENT']) && $_SERVER['HTTP_USER_AGENT']{
                $uri 
.= '_' md5($_SERVER['HTTP_USER_AGENT']);
            
}

Thank you.

 
Magento Community Magento Community
Magento Community
Magento Community
 
dhben
Jr. Member
 
Total Posts:  1
Joined:  2012-02-26
 

Adding the full user agent to the uri is probably not a good idea because you will end up with many different caches. (Theoretically one for every single user agent on the internet)

I created a simple extension which adds the theme to the FPC uri and posted the source on Github.

https://github.com/benjy14/MobileFpcFix

 
Magento Community Magento Community
Magento Community
Magento Community
 
insight
Member
 
Total Posts:  58
Joined:  2008-07-24
 

dhben you champ,

Thanks for the fix works like a charm in 1.13.0.2

 
Magento Community Magento Community
Magento Community
Magento Community
 
Leo Leung
Jr. Member
 
Avatar
Total Posts:  16
Joined:  2012-02-08
 

dhben ‘s solution is great!

I have explored your code, the major fix is to append theme name after the cache request ID.

If you dont mind i would like to share the core part:

//Enterprise_PageCache_Model_Processor
in protected function _createRequestIds() 

// If caching is enabled we append the theme to the URI.
        
if ($uri{
            $theme 
Mage::getSingleton('core/design_package')->getTheme('frontend');

            
// Update the requestId and the requestCacheId.
            
$this->_requestId .= $theme;
            
$this->_requestCacheId  $this->prepareCacheId($this->_requestId);
        
}

Thanks for the fix

 
Magento Community Magento Community
Magento Community
Magento Community
 
Sridhar P
Jr. Member
 
Total Posts:  10
Joined:  2011-02-09
 

Hi,

Installed your fix in my server and i’m getting this error mentioned below when i enable the FPC in cache management.

Fatal error: Call to a member function canProcessRequest() on a non-object in /home/myproj/includes/src/Enterprise_PageCache_Model_Observer.php on line 128

Can anyone help me out…

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top