| 
 
Joomla Performance
Welcome, Guest
Please Login Using Control Panel At Top Of Page or Register.
Lost Password?
Re:need HELP on Joomla's Cache system (1 viewing)
_GEN_GOTOBOTTOM Post Reply Favoured: 0
TOPIC: Re:need HELP on Joomla's Cache system
#2014
iosoft (User)
Expert Boarder
Posts: 35
graphgraph
User Offline Click here to see the profile of this user
need HELP on Joomla's Cache system 2008/04/05 13:32 Karma: 0  
Hi Friend,

Long time no chat....

I am facing a bad cache problem.

Setup: Joomla 1.0.14 + IncludePHP, but without PageCache.
Joomla's Cache system is ON.

Is there any way to force Joomla's Cache system not to cache at all for specific Content IDs ?



Details -

I am using the IncludePHP.
I have a static page that calls a custom form.php (general php form)

say the URL is -
index.php?option=com_content&task=view&id=10&Itemid=100
Now, I want to pass another GET parameter CID (optional),
like this -
index.php?option=com_content&task=view&id=10&Itemid=100&cid=45

If I 1st hit this -
index.php?option=com_content&task=view&id=10&Itemid=100&cid=45
and after that
index.php?option=com_content&task=view&id=10&Itemid=100&cid=55

due to cache problem, it still shows the content of cid=45, not of cid=55 !!
Have to wait for a long time to get the actual page.




Can you please help me on this....
  The administrator has disabled public write access.
#2029
ircmaxell (Admin)
Admin
Posts: 961
graph
User Offline Click here to see the profile of this user
Re:need HELP on Joomla's Cache system 2008/04/08 10:19 Karma: 19  
hehehe, there is a way to do that... But, first off, DO NOT USE 1.0.14, there is a CRITICAL security risk there, upgrade IMEDIATELY to 1.0.15...

Now, with that said, edit /includes/Cache/Lite/Function.php
Near the bottom, you'll see
Code:

 $this->save(serialize($array), $id$this->_defaultGroup);



Replace that with

Code:

 if(!strstr($output,'<!--nocache-->')){ $this->save(serialize($array), $id$this->_defaultGroup); }



now, in any article that you don't want cached, add the HTML comment <!--nocache-->, and it won't be cached...
The biggest obstruction to innovation is not ignorance, but the delusion of knowledge...

JFGI + RTFM will answer 98% of all questions....
  The administrator has disabled public write access.
#2033
iosoft (User)
Expert Boarder
Posts: 35
graphgraph
User Offline Click here to see the profile of this user
Re:need HELP on Joomla's Cache system 2008/04/08 10:39 Karma: 0  
I have only one thing to say -




One more small question -

can't I give the list IDs that will not CACHE instate of that 'nocache' tag, as I think that comparison is very very memory intensive (slow).

Just something like this -

Code:

  if(id!=50 && id!=55 && id!=78) $this->save(serialize($array), $id$this->_defaultGroup);

  The administrator has disabled public write access.
#2036
ircmaxell (Admin)
Admin
Posts: 961
graph
User Offline Click here to see the profile of this user
Re:need HELP on Joomla's Cache system 2008/04/08 10:49 Karma: 19  
Well, I don't know... I've never tried it... Give it a shot...
The biggest obstruction to innovation is not ignorance, but the delusion of knowledge...

JFGI + RTFM will answer 98% of all questions....
  The administrator has disabled public write access.
#2100
iosoft (User)
Expert Boarder
Posts: 35
graphgraph
User Offline Click here to see the profile of this user
Re:need HELP on Joomla's Cache system 2008/04/11 14:11 Karma: 0  
Your CODE is 100% working.

NOTE: that ID is not post id. so can't be used....
  The administrator has disabled public write access.
#2697
markchicobaby (User)
Fresh Boarder
Posts: 2
graphgraph
User Offline Click here to see the profile of this user
Re:need HELP on Joomla's Cache system 2009/05/24 01:11 Karma: 0  
Hi is there a way to turn off the standard Joomla caching for a single article in Joomla 1.5.10?

So far I've had no luck at all....

Thank you!
M
  The administrator has disabled public write access.
#2699
nifini (User)
Fresh Boarder
Posts: 2
graphgraph
User Offline Click here to see the profile of this user
Re:need HELP on Joomla's Cache system 2009/06/05 09:12 Karma: 0  
Tried to put this in /plugins/system/cache.php aroud line
Code:

 $this->_cache->store();


But no luck for now...
Need solution for Joomla 1.5 very much!

Post edited by: nifini, at: 2009/06/05 09:13
  The administrator has disabled public write access.
#2706
paulsschwarz (User)
Fresh Boarder
Posts: 3
graphgraph
User Offline Click here to see the profile of this user
Re:need HELP on Joomla's Cache system 2009/06/17 16:50 Karma: 0  
nifini, this should help you:

in /plugins/system/cache.php find the line that says $this->_cache->store(); and change it to:

Code:

  $uri =& JFactory::getURI(); $path $uri->getPath(); $nocache = array(); $nocache[] = '/ever-changing-page'; $nocache[] = '/app/dynamic.html'; $nocache[] = '/abc.htm';              if (in_array($path$nocache))   return;              $this->_cache->store();



Now you just need to list the aliases of the pages that you want to skip the page cache system. (Note that I'm using sh404SEF so if you're not you may need to modify the code slightly, but it's a start).
  The administrator has disabled public write access.
#2707
nifini (User)
Fresh Boarder
Posts: 2
graphgraph
User Offline Click here to see the profile of this user
Re:need HELP on Joomla's Cache system 2009/06/17 18:03 Karma: 0  
paulsschwarz, thnx a lot for your answer!

It works! But strange a bit.
When Global caching is turned off and plugin "System - Cache" is published - everything is just fine(pages from $nocache[] array are not cached).
But when the Global is on and plugin is published - everything is cached

Could it be that not only /plugins/system/cache.php wich has to be hacked in this case?
maybe /libraries/joomla/cache/cache.php ?

Post edited by: nifini, at: 2009/06/17 20:25

Post edited by: nifini, at: 2009/06/17 20:26
  The administrator has disabled public write access.
#2708
paulsschwarz (User)
Fresh Boarder
Posts: 3
graphgraph
User Offline Click here to see the profile of this user
Re:need HELP on Joomla's Cache system 2009/06/18 03:48 Karma: 0  
Warning: Don't take this as gospel, I'm simply stating my observations, but would appreciate if someone who knows the inner workings could comment

nifini, you're right, and I'm glad you pointed that out... which has lead me to a question about Joomla's caching system. As far as I can see there are two places to set caching settings, System Cache and Global Cache (which can be turned on/off per module).

System Cache seems to place its output in /cache/page

Global Cache places its output in /cache, but filed under com_content, mod_mainmenu, etc.

Now looking at files produced by each it seems as though Global Cache caches individual "parts" depending on the URL, so for a particular request the state of the menu at that moment will be cached, the state of the content will be cached, etc. These "parts" are stored in cache files that look something like this:
Code:

 a:2:{s:6:"output";s:0:"";s:6:"result";s:779:" <div>some html here!</div>    ";}


Those fancy numbers at the beginning are obviously info that tell Joomla how to reconstruct the page. All of this implies that Global Cache tells each part of the page to be cached separately, and then when you access the same URL again the page is rapidly pieced back together and presented to you.

NOW, System Cache seems to behave differently! It seems (even with Global Cache switched off) to simple take a snapshot of the entire page after load. It then stores a hash of the URL you used to access the page, and so when you next view the site, if your request URL matches one in the cache (that hasn't expired) you just get shown the cached file instead of rebuilding it but executing all the plugins and modules again! We could say that this is a more simplistic approach than the Global Cache, but pretty efficient and robust though. In fact, I'd argue that the only time that this approach is worse off that using Global Cache would be when most of your page remains the same but one tiny little module's content changes depending on a GET parameter in the URL. So this means that System Cache will see different requests and therefore build more cached pages, even though they're MOSTLY the same. Having said this, I'm not sure that Global Cache is smart enough to mix and match content that hasn't changed (get it from the cache) and a module that has changed (rebuild it but executing the module) depending on a GET parameter that affects ONLY the module. Can it do this?

If you look at the contents of the files in /cache/page/ you'll see that a complete snapshot of the fully rendered page is saved. Contrast this with the approach of Global Cache where individual "parts" are saved and then have to be reconstituted later. This finally leads me to my questions about Joomla's caching...
  1. Are Global Cache and System Cache supposed to be enabled simultaneously?
  2. Does Global Cache take precedence over System Cache?
  3. Can there be any downside to leaving Global Cache off and enabling System Cache only?
  The administrator has disabled public write access.
#2736
hetOrakel (User)
Fresh Boarder
Posts: 2
graphgraph
User Offline Click here to see the profile of this user
Re:need HELP on Joomla's Cache system 2009/09/13 15:45 Karma: 0  
The hack that works perfectly for me:

In libraries/joomla/cachce/storage/file.php resides the code that actually stores the cache-file.

in the function "store" at approx. line 80:

Code:

     /**      * Store the data to a file by id and group      *      * @access    public      * @param    string    $id        The cache data id      * @param    string    $group    The cache data group      * @param    string    $data    The data to store in cache      * @return    boolean    True on success, false otherwise      * @since    1.5      */ function store($id$group$data) {     /* as first line: */     if(strstr($data,'<!--doNotChacheThisArticle-->')) return true;     ..... /* rest of the code*/  }



Post edited by: hetOrakel, at: 2009/09/13 15:45

Post edited by: hetOrakel, at: 2009/09/13 15:49
  The administrator has disabled public write access.
#2737
paulsschwarz (User)
Fresh Boarder
Posts: 3
graphgraph
User Offline Click here to see the profile of this user
Re:need HELP on Joomla's Cache system 2009/09/14 02:53 Karma: 0  
Thanks for that hetOrakel, I'll take a look at that solution soon. Note that Joomla has two caching mechanisms and I'm still after a good explanation of the subtleties of each. One of the System Cache plugin which seems to cache entire pages, the other is the Global Cache in Global Configuration which I don't fully understand yet. I think it caches modules and components separately and them stitches them together on page request. Correct me if I'm wrong.

So you need to be clear on whether you're tackling the Global Cache or Page Cache (or both)?

I wonder how efficient the method strstr is at finding a string in an entire article? as you've got it here:
Code:

 if(strstr($data,'<!--doNotChacheThisArticle-->')) return true;



It looks like a neat enough hack for articles, how would you use it for general components? I guess you could put <!--doNotChacheThisArticle--> into the (template?) code for the component that you don't want cached?
  The administrator has disabled public write access.
#2738
hetOrakel (User)
Fresh Boarder
Posts: 2
graphgraph
User Offline Click here to see the profile of this user
Re:need HELP on Joomla's Cache system 2009/09/14 04:36 Karma: 0  
Ola, alotoff questions...

paulsschwarz wrote:
Thanks for that hetOrakel, I'll take a look at that solution soon. Note that Joomla has two caching mechanisms and I'm still after a good explanation of the subtleties of each. One of the System Cache plugin which seems to cache entire pages, the other is the Global Cache in Global Configuration which I don't fully understand yet. I think it caches modules and components separately and them stitches them together on page request. Correct me if I'm wrong.

So you need to be clear on whether you're tackling the Global Cache or Page Cache (or both)?


I'm not Sure. But from what i found in the cache-dir it looks like the pieces you're talking about. I only enabled the global cache (as far as i know!).


I wonder how efficient the method strstr is at finding a string in an entire article? as you've got it here:
Code:

 if(strstr($data,'<!--doNotChacheThisArticle-->')) return true;




How big are you're article's? Mine are not that big.... None is bigger then say 1k characters.


It looks like a neat enough hack for articles, how would you use it for general components? I guess you could put <!--doNotChacheThisArticle--> into the (template?) code for the component that you don't want cached?

I'm just a beginner in joomla hacking! I only used it in articles. To be more specific in articles which use jumi plugin....
  The administrator has disabled public write access.
_GEN_GOTOTOP Post Reply
get the latest posts directly to your desktop
feed image
Copyright 2007 Anthony Ferrara, All Rights Reserved