ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Template Caching per user account

January 24, 2011 10:32am

Subscribe [4]
  • #1 / Jan 24, 2011 10:32am

    Dave Joyce

    49 posts

    I turned on template caching for my main page and it GREATLY increased the performance. However, my site is basically a web app that’s highly configurable by the user. Each front page is completely unique to each user account on the site. So when I turned on template caching, it meant that everybody saw MY user account screen.

    Is there a way to cache the templates for individual users?

  • #2 / Jan 24, 2011 11:18am

    Dave Joyce

    49 posts

    Also, I just tried the Dynamic Channel Query Caching as well. It wasn’t as good as the template caching, but it also had the same problem :(

  • #3 / Jan 25, 2011 6:59am

    John Henry Donovan

    12339 posts

    Dave,

    What version and build of EE are you using?

    There is a combination of things to try when optimizing your install.

    What specific issues are you running up against? Is it the actual page load speed or items in the page?
    Do you have a lot of embeds, snippets?
    Are you using PHP?
    Have you looked at tag caching as opposed to page caching?
    How much PHP memory have you got?
    Are you using any add-ons?

  • #4 / Jan 25, 2011 10:49am

    Dave Joyce

    49 posts

    What version and build of EE are you using?

    v2.1.0 Build 20101220

    What specific issues are you running up against? Is it the actual page load speed or items in the page?

    It’s the load speed that I’m very sensitive to because I’m making user customizable start pages. So I need it to be super snappy, but also completely dynamic. It’s not actually a huge page. It’s one channel tag. Here’s a trimmed down version of my page.

    {exp:channel:entries channel="user_pages" sort="asc" order_by="title" author_id="CURRENT_USER" limit="10"}
                
                <div class="page">
                    
                    <div class="site_list">
                        {exp:safecracker safecracker_head="no" id="icon_sort_form_{entry_id}" class="icon_sort_form" channel="user_pages" return="home/index_editable/ENTRY_ID" entry_id="{entry_id}" json="yes"}
                        <ul>
                        
                        {page}
                            <!-- Clip -->
                            
                            <!-- Cycling through a matrix with files, and play fields, and also input fields for the safecracker add on -->
                        
                        {/page}
                        
                        </ul>
                        
                        
                        {/exp:safecracker}
                    </div>
                    
                
                    <a href="http://{url_title_path=%27add_website%27}" class="add_website">Add Website</a>
                    <input type="hidden" name="current_page_id" class="current_page_id" value="{entry_id}">
                    
                    
                    
                </div>
                    
                {if no_results}
                    <!-- Clip -->
                {/if}
                    
                
                
                {/exp:channel:entries}

    Do you have a lot of embeds, snippets?

    Not really.

    Are you using PHP?

    No

    Have you looked at tag caching as opposed to page caching?

    Yeah, tag caching works really well also at speeding it up, but it’s the same problem. It’s not unique to a user. It caches whichever user happens to load their page first.  I used this tag…

    {exp:channel:entries channel="user_pages" sort="asc" order_by="title" author_id="CURRENT_USER" limit="10" cache="yes" refresh="30"}

    I thought the tag caching would work because it has “author_id=‘current_user’” But i loaded it logged in as JOE, then logged in as another user, BOB, and saw JOE’s page. It never caches BOB’s page because JOE got their first.

    How much PHP memory have you got?

    Not sure. I don’t think that’s the problem though. I’m on dreamhost though for what it’s worth.

    Are you using any add-ons?

    Matrix, Playa and SafeCracker primarily

  • #5 / Jan 25, 2011 7:47pm

    Sue Crocker

    26054 posts

    One thing that might help speed up your site is to add disable= settings.

    Have you seen: EEDocs:// Disable Parameters

  • #6 / Jan 25, 2011 8:07pm

    Barry Cogan

    291 posts

    Hi Dave,

    I believe you would be best served by Custom Profile Data for user specific pages.

    Best regards,
    Barry

  • #7 / Jan 29, 2011 5:20pm

    Dave Joyce

    49 posts

    I tried disabling everything except for the custom field that I’m using (a matrix) that basically the whole page is using.  it shaved off maybe half a second or so, but not enough. I’m averaging 3.5 seconds for the document to load and around 4 without disabling anything.

    A static copy of the page document loads in 300ms

    The Custom Profile Data can’t help me because I need more than just one off custom fields. I’ve got entries that use Matrix and Playa in channels that users can modify with SafeCracker.

    I know I’m pushing what EE was designed for by using SafeCracker, but Is it safe to say this is a bug or a feature that EE should have? The description of the tag caching in the user guide is “The Tag Caching system lets you cache the output of individual tags”. But if that individual tag has the author_id=“CURRENT_USER” set, the caching becomes useless.

  • #8 / Jan 29, 2011 11:16pm

    Dave Joyce

    49 posts

    ok, I had something of a breakthrough.

    I guess what’s throwing off the tag caching is the fact that I’ve got a constant setting the author (“author_id=“CURRENT_USER”). So I figured if I had an actual value in there, that would allow EE to see that tag as a separate tag, and cache it separately.

    Well that works! The problem now is setting it. I tried embedding my loop in another template then setting the {member_id} as a variable, but that doesn’t work because the embedded variables are parsed last, so I couldn’t use it as a parameter in my channel entries loop. I’ve got a template set up now that can read the author_id in segment_3, and that works, except I have to load that with javascript in order for it to work since I can’t seem to get a PHP include to load within EE.

    So I guess my question now is, is there a way to set the author_id field in my channel entries loop to the current {member_id}, without using the constant “CURRENT_USER”?

  • #9 / Jan 30, 2011 8:44am

    Dave Joyce

    49 posts

    YES! I think I got it!

    instead of using the constant, I use the {member_id} variable WITHIN the custom profile tag so that it gets parsed first.

    So I’ve got this…

    {exp:member:custom_profile_data}
    
    {exp:channel:entries channel="user_pages" author_id="{member_id}" dynamic="no" cache="yes" refresh="30" disable="categories|category_fields|member_data|pagination"}
    
    <!-- snip -->
    
    {/exp:channel:entries}
    {/exp:member:custom_profile_data}

    And this seems to work like a charm! Thanks for the pointer Barry, that helped me figure it out.

    Out of curiosity though, would it not be possible in a future EE upgrade for the tag caching mechanism to recognize the constant “CURRENT_USER” as a unique set of users with multiple tag caches and not just one?

  • #10 / Jan 31, 2011 4:18am

    John Henry Donovan

    12339 posts

    Great stuff! Your request might be difficult as CURRENT_USER is based on a session. It is worth making a feature request though. Feel free to start a new thread if you have any more questions

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases