Page 1 of 2

Speed up your CMSMS site

Posted: Thu Apr 12, 2007 6:19 pm
by jatinder
Hello,

Here is a method to speed up your CMSMS site considerably.

I have hacked the index.php to implement full page cache. The entire page is cached, not just the content. This has improved page loading time by almost 50% to 80% for me.

I am very new to CMSMS. So let me know if a better solution already exists.

Note: This is meant for version 1.0.4 only. It might work on 1.0.5 also, but haven't tested.

Regards,
Jatinder Singh Thind

[gelöscht durch Administrator]

Re: Speed up your CMSMS site

Posted: Thu Apr 12, 2007 7:19 pm
by Vin
Well, cyberman has got his cache tags: http://dev.cmsmadesimple.org/projects/cache

Your and Cyberman's solution are nice and fast, however, they have disadvantages, a) news pagination or other pages which have 'visible' variables in the URL have no more working links (next/prev)(at least your solution, I can't remember the cache plugin behaviour now), b) hard lifetime. Can't even set the page not to be cached.

Fast though...

Re: Speed up your CMSMS site

Posted: Fri Apr 13, 2007 3:29 am
by jatinder
Cyberman's cache module only caches the {content} portion.

I used the code from his module to cache the whole page.

Any page which has variable "mact" in the $_REQUEST is not cached.  My guess was that "mact" in only present when a module is being called. Though I can't be sure, I haven't worked on CMSMS that much.

I can't find a way to implement pagination in News module. How you do it?

Can you let me know which module won't work with the modified index.php so that I can try to come up with a solution?

Re: Speed up your CMSMS site

Posted: Fri Apr 13, 2007 1:28 pm
by Pierre M.
Dear Jatinder,

I like all efforts to make release full page caching. You remind me of my poor "write(urlfilename, renderedpage) instead of echo renderedpage" in http://forum.cmsmadesimple.org/index.ph ... l#msg37558

v2.0 has it already, according to http://blog.cmsmadesimple.org/2007/02/0 ... your-help/
I'm sure Ted will welcome new devs to help the release of v2.0. Or even a lighter-than-expected v2.0 with "what is done so far", if technically possible, should it be called v1.5 ?

Pierre M.

Re: Speed up your CMSMS site

Posted: Fri Apr 13, 2007 3:43 pm
by Vin
jatinder wrote: I can't find a way to implement pagination in News module. How you do it?
Look here: http://wiki.cmsmadesimple.org/index.php ... fined_Tags
and you may like pagination for backend: http://forum.cmsmadesimple.org/index.ph ... 194.0.html
jatinder wrote: Can you let me know which module won't work with the modified index.php so that I can try to come up with a solution?
It's just the permanent cache. The pagination of News doesn't work, and the content is not updated immediately (sigh).

I can't wait for v2.0 :).

Re: Speed up your CMSMS site

Posted: Fri Apr 13, 2007 4:36 pm
by jatinder
It's just the permanent cache. The pagination of News doesn't work, and the content is not updated immediately (sigh).
Oh yes, it does  :). I have another hack for the admin section which deletes the cache file when a page is updated.

I will check with the pagination though. Thanks for the link.

Re: Speed up your CMSMS site

Posted: Fri Apr 13, 2007 6:27 pm
by Vin
jatinder wrote: Oh yes, it does. I have another hack for the admin section which deletes the cache file when a page is updated.
That would be nice :). (I've been thinking about checking the expiration date with the query to the database in index.php, but this is  far more better :)). And does it work even for modules? For instance, News are updated in its own admin.

I turned off 'pretty urls' and looked at the 'mact' variables. The pagination doesn't use it, that's apparently why it's loading the cache.

Updated index.php

Posted: Sat Apr 14, 2007 3:56 am
by jatinder
I have made another modification to the index.php page. The pages are now cached only when they are marked as "Cachable".

So I guess even News pagination should work now if you set the particular page as non cachable. Can somebody please confirm this?

I am also posting the modified admin/editcontent.php script. This script includes a single line modification, which deletes the cache file when a page is updated.

[gelöscht durch Administrator]

Re: Speed up your CMSMS site

Posted: Sat Apr 14, 2007 7:19 am
by Vin
Great! Just a little modification/fix:

You can leave the caching for modules now (it seems it's not much a difference, but better than nothing), and it doesn't output warnings when updating a content which hasn't been cached yet (see both attached files).
[edit] Fix to fix :)(jatinder, the content_alias instead of content_id was being encrypted in editcontent.php - so it wasn't working)
[edit]Oh, and know you should have your menu template already sorted out - it caches it. The same goes with all other templates. However, adding new content/menu items is not a problem.

[gelöscht durch Administrator]

Re: Speed up your CMSMS site

Posted: Sat Apr 14, 2007 2:02 pm
by macyogi
Vin wrote: Great! Just a little modification/fix:
I tried the last posted version (by Vin) on a site based an 1.04 (german) . I found that the last lines are in double:
--
echo 'BackUrl().'">« '.lang('back').'';

include_once("footer.php");

# vim:ts=4 sw=4 noet
?>
--
Unfortunately, no page is cached anymore. The 'cachable' checkbox is cheched on every page. Maybe something went wrong during the last fixes?

Another suggestion:  could you please modify the comment "Generated in xxx seconds ..." to clarify that the page is generated from cache? Could be line 212 in index.php

Thanks for you work. Using your modified code (from yesterday) speeds up my site by 80% and more.

Re: Speed up your CMSMS site

Posted: Sat Apr 14, 2007 4:31 pm
by Vin
I have the feeling it collided with the 'timer' of Jatinder. It should be fixed by now. Yet another update (with the cached notice) (NOW SWITCH THE CACHE OFF IN THE CASE OF MODULE (It's not much difference after all)):
P.S.
echo 'BackUrl().'">« '.lang('back').'';

include_once("footer.php");
What do you mean?

[gelöscht durch Administrator]

Re: Speed up your CMSMS site

Posted: Sat Apr 14, 2007 6:12 pm
by jatinder
You can leave the caching for modules now
Vin, your code is actually caching the modules. The index.php I posted, does not cache the modules.

Some modules don't work properly if you cache their output. For example, the validation on FeedbackForm won't work if the module output is cached.

Edit:

I have just downloaded CMSMS v1.0.5. My modified index.php will work with the with 1.0.5 also.

Re: Speed up your CMSMS site

Posted: Sat Apr 14, 2007 9:03 pm
by Vin
jatinder wrote:
You can leave the caching for modules now
Vin, your code is actually caching the modules.
Apparently, it did some. I shouldn't have relied on that trick I had in the index.php, my fault. So it seems there's no possibility for the modules to be properly cached now.
It would be nice to have the proper caching for the modules as well. Currently looking at the moduleinterface.php and classes.
jatinder wrote: I have just downloaded CMSMS v1.0.5. My modified index.php will work with the with 1.0.5 also.
Good to hear :).

Re: Speed up your CMSMS site

Posted: Sat Apr 14, 2007 9:42 pm
by Vin
Vin wrote: However, adding new content/menu items is not a problem.
I've recently found out that the menus are updated only if you do something in Content » Pages - e.g. deactivating/activating the page (in Content » Pages, the list of pages; not the page editing itself).

Re: Speed up your CMSMS site

Posted: Sun Apr 15, 2007 9:18 am
by macyogi
Hi Vin,
on my sites I am using my own routine for the navigation. This means that individual pages will be addressed by their alias not by their ID (e.g. : index.php?page=home). This results in a wrong md5 encryption of $page in index.php for writing or reading the cache. Furthermore the cache could not be deleted after editing, because the page in the admin section is addressed by ID.

I do not know if others do address pages by the alias too, but if so, I would suggest to turn line 199 in index.php from

$mcv = './tmp/cache/thind_' . md5($page) . '.inc.php';

to

$mcv = './tmp/cache/thind_' . md5($pageinfo->content_id) . '.inc.php';

Greetings