Enabling Smarty Caching

Discussion in 'Customization & add-ons' started by joe_asto2, Jan 4, 2007.

  1. joe_asto2

    joe_asto2 New Member

    Joined:
    Aug 22, 2006
    Messages:
    68
    Alex said here that, "If your site doesn't handle 100,000 AMEMBER pages views daily, you don't need this caching." (meaning Smarty caching)

    I am expecting that kind of traffic on my site, and despite the apparent fact that, "Smarty is useless on shared hosts because of permission problems. We have this resolved but with some performance penalty" because caching cannot be enabled, on my host, which is the equivalent of a VPS (Virtual Private Server), the user permissions setup is very different to that of a normal shared hosting environment.

    This means the user permissions on my server allow the generation of Smarty cache files and folders without problems. (I am soon moving to a dedicated server anyway)

    If I changed the following in Smarty.class.php from,
    PHP:
    var $caching         =  0;
    to,
    PHP:
    var $caching         =  2;
    could I turn on Smarty caching in aMember without problems?

    If this won't enable Smarty caching for aMember, how else can I enable it?

    Thanks very much for your help! :)
  2. jenolan

    jenolan aMember Coder

    Joined:
    Nov 3, 2006
    Messages:
    510
    Smarty does some cache data by default, the problem is that if you turn the full cache on it generates static pages which I would pretty much be sure you would not want.

    You have my email send over some information on the numbers of emmbers, how many online at once, your system and I will give you some idea compared to us.

    Don't get too hot about cache operation though (of smarty) there are more productive ways to speed up php processing.

    Larry
  3. joe_asto2

    joe_asto2 New Member

    Joined:
    Aug 22, 2006
    Messages:
    68
    Sounds good to me!

    This is actually what I need. The site content will always be the same unless a user is logged in.

    This means I want to have static cache pages ready to be served up to any site visitor who isn't logged in. If a user then logs in, dynamic pages would be generated for them.

    How can I enable this?

    Thanks for your help!
  4. jenolan

    jenolan aMember Coder

    Joined:
    Nov 3, 2006
    Messages:
    510
    No no .. static means that they are static totally absolutely 100% everyone will get the page that was generated first no matter who it was, what level of access, whatever.

    You can't use static pages with a membership page :)

    In fact you can not use static pages anywhere where user information is used.

    If you want a set page for non members (or whatever) create a html page with the required links.

    Larry
  5. joe_asto2

    joe_asto2 New Member

    Joined:
    Aug 22, 2006
    Messages:
    68
    I meant what I said.

    I need static cache files available for all the pages of the site except member.php and profile.php (where caching won't be enabled).

    If a user is logged in no cache files will be served anywhere, and login forms will be replaced with member-only links. This is why I need to use smarty on my non-amember pages (I can't just use html files like you suggest), and why I need caching enabled.

    To help you understand, I'm using the following code on all my non-amember pages:

    PHP:
    <?php
    if ($au=$_SESSION['_amember_user']){ // user is logged-in
      
    print "member-only links go here";
    } else { 
    // user is not logged-in
      
    print "login form goes here";
    }
    ?> 
  6. jenolan

    jenolan aMember Coder

    Joined:
    Nov 3, 2006
    Messages:
    510
    Ummm

    If you are going to write it that way don't use Smarty at all, the best Smarty does is basically cache it to html. If you do the above then you are already as far a Smarty caching will get you.

    To make the system perform better you would need to use one of the accelerator (system level cache) widgets like eaccellerator but most of them do not like the encoder use by aMember.
  7. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    Instructions to enable Smarty caching, try it
    1. create and chmod 777 folder amember/templates_c/

    2. edit amember/common.inc.php
    replace
    PHP:
    function new_smarty(){
        global 
    $config;
        require_once(
    $config['root_dir'].'/smarty/SmartyNoWrite.class.php');
        
    $t = new _SmartyNoWrite();
        
    $t->force_compile 1;
        
    $t->compile_check 1;
    to
    PHP:
    function new_smarty(){
        global 
    $config;
        require_once(
    $config['root_dir'].'/smarty/Smarty.class.php');
        
    $t = new _Smarty;
        
    $t->force_compile 0;
        
    $t->compile_check 1;
    try it carefully, specially aMember CP -> E-Mail Users function.
  8. joe_asto2

    joe_asto2 New Member

    Joined:
    Aug 22, 2006
    Messages:
    68
    Thank you Alex!

    WOW! It's so much faster! :)

    Thank so much Alex for helping me out with this.

    I'll report back if I discover any issues.
  9. joe_asto2

    joe_asto2 New Member

    Joined:
    Aug 22, 2006
    Messages:
    68
    Emailing Users Issue - empty message body sent!

    With the above common.inc.php modifications in use, the following occurs:

    When using the "Email Users" feature of the aMember Control Panel, aMember sends empty emails to the users in whatever category you select. Here's a sample message:
    ________________________________________________

    email subject goes here

    -------------------------------------------------------------------
    To unsubscribe from our periodic e-mail messages, please click the following link:
    http://www.domain.com/amember/unsubscribe.php?e=user@domain.com&s=3c48

    -------------------------------------------------------------------

    ________________________________________________

    As you can see, the email subject you specify in the aMember CP is included into the body of the email, but the Plain Text / HTML isn't!

    Is there a workaround for this? Thanks again for your help Alex! :)
  10. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    Joe,
    we will work this around, please submit a ticket to helpdesk.

Share This Page