Question

I want to implement Full Page Cache, but currently I have 1 issue to deal with.

We work with E-Commerce system, which is based on Zend's and Varien library : Magento E-commerce Community Edition.

I am able to cache output, the only problem is, how to deal with following situation:

User comes to site, then goes to catalog/product and adds some product to cart, then goes back to catalog.

The problem is that when he adds a product to cart, there are some particular blocks, which might need to be updated. So I can disabled caching post requests, but how I can update some particular block or how to implement this "placeholder", which will be updated? I suppose there might be some "Best practices" or Patterns for caching.

P.S. To magento guys: please don't remind me about Enterprise edition and payed modules.

Was it helpful?

Solution

There are three ways to gain a much better performance using Magento Community Edition:

1. Use Varnish

Varnish (https://www.varnish-cache.org/) calls itself "web application accelerator" and is a transparent reverse proxy. If you know Squid, than you have a vague idea - Varnish is like Squid, only smarter and faster. :)

Using Varnish, you are able to implement your own Full Site Cache, which can be - in my experience - even much faster than the Full Page Cache of the Magento Enterprise Edition.

However, Varnish is not a standard tool, so if you hosting your Magento installation in just an ordinary PHP webspace package, you might not be able to install/use it. To install and use Varnish you need to have (root) access to your system or a provider, which offers you Varnish as a service. There are some Magento hosting providers out there, which offers special Magento hosting, including services like Varnish.

Varnish itselfs caches all kind of static files amd pages, e.g. whole product view pages. So, if you start using Varnish you need to adapt your Magento, i.e. create a specific modules, which seperates your pages into static and dynamic content.

For example: The product view is one page with placeholders for the dymaic parts/blocks, like the cart widget. The static content (page) will be delivered by Varnish, the dynamic content will be loaded by the client (browser) doing AJAX calls to your application server (Magento).

So your application server(s) will only called for those dynamic blocks and the checkout/customer login and you can save tons of performance.

There are already a few Magento module for Varnish, like http://www.magentocommerce.com/magento-connect/pagecache-powered-by-varnish.html - just Google for "Varnish Magento", you'll find enough informations.

2. Build your own cachesystem

Instead using Varnish you could build your own, simple (and stupid) cache system. Nothing is faster as pure, static HTML pages. So the simplest kind of cache I can think of (and already implemented myself) is a stupid cronjob, which crawls your shop regulary, storing the product pages as static HTML page. The dynamic content (again cart widget,...) should be replaced with placeholders.

Now you can deliver those static HTML pages to clients, which are browsing your shop very fast - because they are static. The dynamic content has to be replaced on the client's side (browser) using AJAX calls to your system, again.

Stupid, but simple and works fine - as long as you don't have thousands of products (crawling would take too long).

3. Don't use Magento

Just a joke,... :) But yes, Magento tends to be slow.

Also very useful for Magento performance optimizations: The Magento Best Practice for Performance and Scalibilty Whitepaper. Even it's for the Enterprise Edition, some tips are also very useful for the Commiunity Edition.

OTHER TIPS

Open source full page cache for magento

https://github.com/ezapps/Zoom-Magento-FPC

Works very fast and it's free. On magento commerce you have simular extensions that charge $500 per domain

i think you need put a identify id, which change when the customer add a producto to cart

    protected function _construct()
{
$this->addData(array(
'cache_lifetime' => 3600,
'cache_tags'     => array(Mage_Catalog_Model_Product::CACHE_TAG),
'cache_key'      => $this->getProduct()->getId(),
));
}

the value of cache_key will need change when you add a product. Can you try it??

this question - magento open source full page cache - deals with some of the issues and modules available to you in this area.

there's a large scope for things to go wrong with a full page cache. magento makes checks before adding a product to cart etc but what you display to your users could be wrong, this could include pricing and other important areas.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top