Is there any way in Magento where you can forcefully generate cache for only one page?
Something like adding a parameter after the URL similar to the following:
http://localhost/computers.html?cache=true?
I am working on development and don't want to enable cache for all the pages for debugging purposes, but would like to see some pages with cache how they are performing.
2 Answers 2
Off the top of my head, I think the problem you're going to have is that by the time the application reaches a point where you can check for request params (ie. Mage::getRequest()->getParams()) the system has already determined if we're using cache or not.
You could try programmatically enabling the cache in an observer of an early event, setting all blocks to not be cached, setting your block to be cached in the block's constructor, then disabling cache programmatically in an observer of a late event. I'm just not sure the events you'll need will be there.
-
That makes sense. But the idea to view cached and non-cached pages was to simplify the things so everytime I don't have to flush/build cache. I don't want to write custom module for that :(MagExt– MagExt2015年03月03日 22:51:44 +00:00Commented Mar 3, 2015 at 22:51
-
As mentioned in the Q's comments, you might as well just leave cache off during development. I don't think there's going to be massive differences in load times for cached/uncached if you're the only person on the site. If your code is that slow without caching on, you probably need to rethink your strategy.pspahn– pspahn2015年03月03日 23:14:00 +00:00Commented Mar 3, 2015 at 23:14
There is this:
https://github.com/ticean/magento-shell-tools
You can disable all cache from the command line (or put some little shortcut for it) and then when you are done you can enable it again.
This is not exactly what you were after but you will be able to do what you want without having to add something to the url.
If you are insistent on going the url route you could have some rule in htaccess that does a redirect to some script that runs the shell script first, then strips the tag on the url and returns you the page.
-
Thanks. I thought it should be possible in Magento itself which now seems it's not.MagExt– MagExt2015年03月03日 22:54:19 +00:00Commented Mar 3, 2015 at 22:54
__nocache. Or maybe without the double underscore. Can't verify that atm.