• Resolved stcyrill

    (@stcyrill)


    The plugin seem to cache “Password Protected Posts”.
    Therefore a password-protected post returns
    both a password form and a post whether cached or not.

    I think the plugin should check $post->post_password
    in cache_control_nocacheables function,
    and do not cache if true.

    
    function cache_control_nocacheables() {
            global $post;
      	    $noncacheable = ( is_preview() ||
     	                      is_user_logged_in() ||
    	                      is_trackback() ||
    	                      is_admin() ||
                              $post->post_password );
    

    Thank you for reading.

    • This topic was modified 7 years, 10 months ago by stcyrill.
    • This topic was modified 7 years, 10 months ago by stcyrill.
    • This topic was modified 7 years, 10 months ago by stcyrill.
Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Dan

    (@geekysoft)

    Therefore a password-protected post returns both a password form and a post whether cached or not.

    This sounds like a theme error.

    Let’s see. So we’d want to cache password protected posts, but only when the password is not provided. I’ll do some testing, but I believe I’ll end up adding the following conditional to $noncacheable:

    (!empty($post->post_password) && !post_password_required())

    Plugin Author Dan

    (@geekysoft)

    @stcyrill, would you please help by testing revision 1663525 (or full script file)?

    Thread Starter stcyrill

    (@stcyrill)

    @geekysoft

    Thank you for repling me about this issue.

    I tried a patch(revision 1663525), it’s OK after password form passed.
    However, it’s contained !post_password_required() in if condition,
    therefore it returns Cache-control header in password form page.

    Could you remove !post_password_required() in cache_control_nocacheables?

    Thank you for reading.

    Plugin Author Dan

    (@geekysoft)

    The intention was to return the password form unless the right password is provided. This is the public page that is accessible to anyone, right? So you’d want this to be cached. When the user is logged in and have unlocked the article, then the page is tagged as non-cacheable.

    Thread Starter stcyrill

    (@stcyrill)

    @geekysoft

    Yes, the password form page is public.
    However, if this page is cached, it becomes to return password form in spite of valid password because of redirection to same URL.

    Thank you for reading.

    Plugin Author Dan

    (@geekysoft)

    However, if this page is cached, it becomes to return password form in spite of valid password because of redirection to same URL.

    You need to Vary by cookie to serve different pages based on [the WordPress login] cookie. This is not a problem with the plugin.

    Thread Starter stcyrill

    (@stcyrill)

    Right. I’ll try “Vary header” way to treat a cache.

    Thank you a lot.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Seem to cache password post’ is closed to new replies.