Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
litespeed_wiki:cache:litemage:troubleshooting:cloudflare-cache-should-be-disabled [2017/11/07 22:11]
Jackson Zhang created
litespeed_wiki:cache:litemage:troubleshooting:cloudflare-cache-should-be-disabled [2017/11/09 19:07] (current)
Jackson Zhang
Line 1: Line 1:
-====== Turn off cache on Cloudflare ​when using Magento and LiteMage ====== +====== Turn Off Cache on Cloudflare ​When Using Magento and LiteMage ====== 
-If you want to use cloudflare ​or other CDN in front of your Magento, make sure you turn off cache there, only enable ​media cache such as css,js,jpg etc. Otherwiseyou will break Magento as well as LiteMage.+If you want to use Cloudflare ​or another ​CDN in front of your Magento ​store, make sure you turn off the CDN's page cache. You may enable ​caching of static files such as CSS,JavaScriptand media filesbut leave the caching of dynamic pages to LiteMage. Engaging Cloudflare'​s page cache will break Magento as well as LiteMage.
  
-For example, if you see header from like the following: ​+For example, if you see headers ​like the following: ​
   "​cache-control:​public,​ max-ago=14400" ​   "​cache-control:​public,​ max-ago=14400" ​
   "​cf-cache-status:​ HIT"   "​cf-cache-status:​ HIT"
  {{ :​litespeed_wiki:​cache:​litemage:​litemage-cloudflare-incorrectcachesetting.png?​300 |}}  {{ :​litespeed_wiki:​cache:​litemage:​litemage-cloudflare-incorrectcachesetting.png?​300 |}}
    
-then you already break your magento ​store and you should unset all these caches from CloudFlare. Why?+that is an indication that Cloudflare is breaking ​your Magento ​storeand causing undesired behavior. You can fix this by turning off Cloudflare'​s page cache. Why?
  
-You will need to understand how Magento works. Magento requires frontend and frontend_cig cookie to be set. Also Magento ​need form key from each user for the validation process.+It helps to understand how Magento works. Magento requires ​a ''​frontend''​ cookie ​and a ''​frontend_cig'' ​cookie to be set. Also Magento ​needs a form key from each user for the validation process.
  
 {{ :​litespeed_wiki:​cache:​litemage:​magento-frontend-cockie.png?​600 |}} {{ :​litespeed_wiki:​cache:​litemage:​magento-frontend-cockie.png?​600 |}}
Line 15: Line 15:
 {{ :​litespeed_wiki:​cache:​litemage:​litemage-formkey.png?​600 |}} {{ :​litespeed_wiki:​cache:​litemage:​litemage-formkey.png?​600 |}}
  
-If cloudFlare ​cache was enabled ​incorrectly, then you can not get frontend and frontend_cig ​cookie ​in the header anymore. Hence all the form_key served from CloudFlare ​cache will be the same, which will cause Magento validation failure(require ​different form key from the different ​user. If user try to add the product to shopping cart or add to compare list, the operation will fail.+If Cloudflare'​s page cache is enabled, then you cannot ​get the ''​frontend'' ​and ''​frontend_cig''​ cookies ​in the header anymore, and as such, every ''​form_key'' ​served from Cloudflare'​s ​cache will be the same. This causes a Magento validation failure, as a different form key is required ​from each user. If user tries to add product to the shopping cart or to the compare list, the operation will fail.
  
-The solution ​is to clean all caches from Cloudflare ​but only keep media cache if you want to.+LiteMage ​is smart enough ​to handle this situation in its page cache, but Cloudflare ​and other CDNs are not.
  
 +The solution is to turn off all Cloudflare caching for dynamic content, keeping only static files such as CSS, JS, JPG, PNG, etc. and leave the page caching to LiteMage. The correct header should be:''​cache-control:​ no-store, no-cache''​
  
 +{{ :​litespeed_wiki:​cache:​litemage:​troubleshooting:​litemage-cloudflare-correctcacheheader.png?​500 |}}
  • Admin
  • Last modified: 2017/11/07 22:11
  • by Jackson Zhang