I found an interesting workaround for an issue I was having; not sure if it's best-practice, but I was wondering if someone could explain to me how this works:
- I needed to provide a check on postdispatch for a category load
- Created an observer, inspect the
Mage::registry('current_category')
- If the category matches the category in question, I do some
getStoreConfig
inspection to a custom module, and based on the return, I either do nothing (let the request sail through) or redirect to another page
What I found is that with Enterprise Full Page Cache enabled, my postdispatch event was never firing.
Which raises the question:
http://cdn.meme.li/i/o5acb.jpg
My solution:
In my custom module's controller I created a new action which effectively just calls $this->_forward()
to the category as before. But now, instead of FPC intercepting my event, the event is fired correctly.
My question:
Is this poor practice?
Is there a better suggested workaround?
It seems less "hacky" than fully disabling FPC for the category in question… though that may have been the actual result of the _forward
. The end-user experience is seamless and all category features work as-expected from there including pagination, layered navigation.
Best Answer
I think it is better to do it next way:
Create observer on post dispatch
Check there if category matches the category in question - set
no_cache
param into the request:(see
Enterprise_PageCache_Model_Observer::checkCategoryState()
). So, only categories which should be redirected won't be cached by FPC.