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 & Comment Previews

September 20, 2007 11:33am

Subscribe [2]
  • #1 / Sep 20, 2007 11:33am

    Dom Stubbs

    156 posts

    After a few slightly nervous minutes of digging through my code and testing a few alternative bits of code, I’ve realised that template caching does not appear to be compatible with comment previews. Not if the preview page is a cached template, anyway.

    I suppose that’s quite logical really, but what I’m hoping is to find a way to make previewing a comment one of the ‘certain events’ that results in the cache being cleared. It works for submitting a comment, so to my mind it would be logical if it also worked for previewing one.

    I know that I can make this work by having my comment preview on an alternative template, but I really would like the preview to be a 1:1 representation of what will actually happen when the user hits the submit button. Turning the cache off isn’t at all desirable either, as it’s a relatively complex page.

    Can anyone shed any light on this? Thanks.

  • #2 / Sep 20, 2007 11:54am

    Robin Sowell

    13255 posts

    Hm- what build and version are you running?  I took a look at the code, if I understand correctly, looks like it should be clearing the cache on the preview page:

    $FNS->clear_caching('all', $_POST['PRV']);

    But- I don’t cache comment pages (they can really fill up the cache quickly), so I’ll need to do some testing to see what’s up.  So- let’s see if you’re on the latest build so we know where we stand.

  • #3 / Sep 20, 2007 12:03pm

    Dom Stubbs

    156 posts

    It’s on 1.6 but not the most recent build. We’re on 20070627 currently.

    I’ve double-checked and things definitely run smoothly if I disable caching. As soon as it comes back on the preview is rendered useless, whilst the submission still works perfectly.

    I appreciate your point about caching comment pages, but the site in question has around 25k entries, each of which represents a fairly complex page, so caching is desirable. Most won’t have any comments and most probably won’t even be loaded that frequently, but for those that are caching appears to be fairly beneficial.

  • #4 / Sep 20, 2007 12:30pm

    Robin Sowell

    13255 posts

    Hm- I confirm, the preview doesn’t show if it’s on the same template as the form and the template is cached.  Actually?  The very first comment I previewed did show- but then after that- no.  And I’m not sure why.  For posterity, here’s what I’m using to test- on latest install:

    {exp:weblog:entries weblog="reading" orderby="date" sort="desc" limit="1" disable="trackbacks"}
    {title}
    {/exp:weblog:entries}
    
    {exp:comment:entries sort="asc" limit="20"}
    
    {comment}
    
    By {name} on {comment_date format="%Y %m %d"}
    
    {/exp:comment:entries}
    
    
    
    
    {exp:comment:preview}
    {comment}
    {/exp:comment:preview}
    
    
    
    
    {exp:comment:form weblog="reading" preview="site/test"}
    
    {if logged_out}
    
    Name: <input type="text" name="name" value="{name}" size="50" />
    
    Email: <input type="text" name="email" value="{email}" size="50" />
    
    Location: <input type="text" name="location" value="{location}" size="50" />
    
    URL: <input type="text" name="url" value="{url}" size="50" />
    
    {/if}
    
    <textarea name="comment" cols="70" rows="10">{comment}</textarea>
    
    <input type="checkbox" name="save_info" value="yes" {save_info} /> Remember my personal information
    
    <input type="checkbox" name="notify_me" value="yes" {notify_me} /> Notify me of follow-up comments?
    
    {if captcha}
    
    Please enter the word you see in the image below:
    
    {captcha}
    
    <input type="text" name="captcha" value="{captcha_word}" maxlength="20" />
    
    {/if}
    
    <input type="submit" name="submit" value="Submit" />
    <input type="submit" name="preview" value="Preview" />
    
    {/exp:comment:form}

    Let me check with the crew on this one- I’m not sure if it’s a case of a bug- or a need for a feature request.  Looking at the code, I thought it should work. 

    Hm- wonder if it’s a browser cache thing instead.  Nope- just turned cache off in FF and tried posting- preview still isn’t showing.  I’ll talk to the crew, get back to you with some more info.

  • #5 / Sep 20, 2007 1:53pm

    Dom Stubbs

    156 posts

    Much appreciated Robin.

  • #6 / Sep 20, 2007 8:57pm

    Derek Allard

    3168 posts

    Thanks Dom, this is unexpected behaviour, and we’re working on it.  We’ll try to get a fix out shortly, but for now you’ll need to either turn off caching, or use a separate, non-cached template.

    Thanks again for brining it to our attention!

  • #7 / Sep 21, 2007 12:34pm

    Dom Stubbs

    156 posts

    No problem, I look forward to the fix. I assume it will be in the next build?

  • #8 / Sep 21, 2007 3:48pm

    Derek Allard

    3168 posts

    That’s the plan, you bet.  Have a great weekend.

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

ExpressionEngine News!

#eecms, #events, #releases