1
Mithrandir
Module-wide caching - Important development

Draven has looked closely into this and found out why (at least some) modules don't work properly with the module-wide cache.

--=Important Bit=--

The header.php checks if there is a cached version of the requested page by seeing if the $xoopsOption['template_main'] is set, but since most modules include header.php as one of the first pages, the $xoopsOption['template_main'] will read system_dummy.html and not found as cached.

Therefore all the php code will be re-executed including SQL sentences and everything.

So to properly benefit from the module-wide cache, start every page of your module to first include mainfile.php, then determine which template to use (if it is necessary to evaluate and not just specify it) and set it with $xoopsOption['template_main'] = 'templatename';
BEFORE including root/header.php.

--=/Important Bit=--

2
Draven
Re: Module-wide caching - Important development
  • 2004/1/28 22:41

  • Draven

  • Module Developer

  • Posts: 337

  • Since: 2003/5/28


Yep, that little bugger drove me nuts for a few hours trying to figure out why the cached pages "appeared" to work, but yet all the SQL calls in the module were still being made (as seen through the MySQL debug window). The culprit, as Myth mentioned above, was the improper placement of the header include.

3
brash
Re: Module-wide caching - Important development
  • 2004/1/28 23:03

  • brash

  • Friend of XOOPS

  • Posts: 2206

  • Since: 2003/4/10


Damn nice find there Draven . This could provide some pretty significant performance increases for people, especially for those with low end servers.

4
sunsnapper
Re: Module-wide caching - Important development

Perhaps we could make this post sticky... and each module developer can post to this thread when they have updated their module with this fix.

5
brash
Re: Module-wide caching - Important development
  • 2004/1/29 0:08

  • brash

  • Friend of XOOPS

  • Posts: 2206

  • Since: 2003/4/10


Very good suggestion ^^

6
Mithrandir
Re: Module-wide caching - Important development

Team and Server Booking modules will be updated shortly with this.

The next News module will of course also include this solution.

7
dlh
Re: Module-wide caching - Important development
  • 2004/1/30 5:45

  • dlh

  • Posts: 182

  • Since: 2002/2/20


Draven,

Thanks for the find. This is pretty huge.

Wierd how it was something so simple, huh? Makes you want to smack your forehead and do a Homer Simpson.

"DOH!"



Dan (dlh)


8
Herko
Re: Module-wide caching - Important development
  • 2004/1/30 10:18

  • Herko

  • XOOPS is my life!

  • Posts: 4238

  • Since: 2002/2/4 1


Topic has been Stickyed

Herko

9
recupsoft
Re: Module-wide caching - Important development
  • 2004/1/31 21:36

  • recupsoft

  • Friend of XOOPS

  • Posts: 151

  • Since: 2003/10/30


Such XOOPS improvements are really welcome

But... for bad programers as me,
Can you provide an example of code before/after

10
Mithrandir
Re: Module-wide caching - Important development

Before:
include ('../../mainfile.php');
include (
XOOPS_ROOT_PATH.'/header.php');

code[...]

$xoopsOption['template_main'] = "templatename";

code [...]

include (
XOOPS_ROOT_PATH.'/footer.php');
?>

after:
include ('../../mainfile.php');

code[...] //As little as possible, to determine template name

$xoopsOption['template_main'] = "templatename";
include (
XOOPS_ROOT_PATH.'/header.php');

code[...] //Main code area

include (XOOPS_ROOT_PATH.'/footer.php');
?>

Login

Who's Online

235 user(s) are online (87 user(s) are browsing Support Forums)


Members: 0


Guests: 235


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits