1

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.

3
  • The wrong mindset. Set your targets for uncached. Make those and you don't have to worry about the cached version.
    – user4351
    Mar 3, 2015 at 17:44
  • Well, I want more uncached pages and very few cached ones. Thanks for suggestion though.
    – MagExt
    Mar 3, 2015 at 17:45
  • It's easy to run with cache abd use a cookie to turn it off. Then all you need is a bookmarklet to control that via browser. I'm quite sure examples can be found with some google-fu. The cookie should be named __nocache. Or maybe without the double underscore. Can't verify that atm.
    – user4351
    Mar 3, 2015 at 17:54

2 Answers 2

1

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.

2
  • 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
    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
    Mar 3, 2015 at 23:14
0

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.

1
  • Thanks. I thought it should be possible in Magento itself which now seems it's not.
    – MagExt
    Mar 3, 2015 at 22:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.