WP Super Cache
Logged in but actually not (35 posts)

  1. Lunarll
    Posted 5 years ago #

    Hi, I've recently gotten my WordPress blog up and running and I've been wondering it there's anyway to keep WP-Super-Cache from displaying me as logged in when I'm actually not short of returning to dynamic pages. The problem is that when I log out on a page, the appearance of the page remains the same as if I were actually logged in.

    Any help would be appreciated. ^^
    Thanks for your time.

  2. Donncha O Caoimh
    Plugin Author

    Posted 5 years ago #

    You should try the debug system in the plugin. Limit it to your IP address and log to a file that you monitor when you load a page. It will tell you what the plugin is doing.

  3. dspilka
    Posted 4 years ago #

    I have this same issue. We display a message in the header of most pages stating something like "Dear ${username}, you are logged in. Log out here.". When I log out it still displays this, even though it did log me out.

    I tried the debugging and that hasn't helped me.

    If I do a shift refresh (hold down shift while doing a refresh) it fixes this. So this might be browser cache related. But we can't expect typical end users to do this.

    Any ideas?

  4. Donncha O Caoimh
    Plugin Author

    Posted 4 years ago #

    dspilka - odd, sounds like the browser is caching the page. Does anything else on the page indicate that you're logged in (like edit links on posts)?

  5. dspilka
    Posted 4 years ago #

    Sorry for the late response. Yes, there are other things on the page indicated I'm logged in. The edit links on posts show up and with the newest WordPress, the admin bar atop the page still shows.

    I'm not sure what to try/do.

  6. Ron Rennick
    MultiSite Guru
    Posted 4 years ago #

    Have you updated to the latest version of supercache or tried the dev version?

  7. dspilka
    Posted 4 years ago #

    This is with Super Cache Version, set not to cache for known users. I have not tried the dev version.

  8. Donncha O Caoimh
    Plugin Author

    Posted 4 years ago #

    How do you create that logged in message? From the WordPress login credentials or some other cookie? Try using the debug system in the plugin to figure out what file gets served when you see this and why.

  9. dspilka
    Posted 4 years ago #

    The logged in message checks the is_user_logged_in() function. The problem isn't only with the logged in message though. As I mentioned above, the posts have their edit links and the admin bar shows like you're logged in. I'll keep trying.

    I'm curious if the thread starter (Lunarll) is still seeing this or found a solution.

  10. Donncha O Caoimh
    Plugin Author

    Posted 4 years ago #

    Use the debug system - it'll tell you a lot about what cached page is being served. What you're seeing shouldn't be happening at all.

  11. Leirith
    Posted 4 years ago #

    I everyone. I am having the same problem as dspilka. I'll see what I can learn from the debug messages and update this thread when I'm done.

  12. Leirith
    Posted 4 years ago #

    I had a look at the log and the cached page that WP Super Cache is serving. By the look of things, WP Super Cache has only cached the "not logged in" version, as expected.

    It seems though that after clicking the "Log out" button, the web server returns a status code of 304, so the browser returns the version from its own cache. Could this behaviour be caused by WP Super Cache? I am doing this on a test server and have not set up and caching myself.

  13. Leirith
    Posted 4 years ago #

    Yesterday I deleted the cache, this morning I've did a search in the wp-content/cache/supercache directory for pages that are cached when the user is logged in. It returned one result: a HTML page showing "Logged in as <username>", so WP Super Cache does seem to be caching visits by known users, even though the setting says it shouldn't.

    The stats page says WP-Super-Cache currently contains 4746 Cached Pages, but WP-Cache contains 0 Cached Pages. It was my understanding that WP-Cache was meant to be used for known users. Is it not working correctly?

    What can I do about this?

  14. Leirith
    Posted 4 years ago #

    I checked the WP Super Cache log at the time when one of the files was created.

    10:53:40 /2010/01/<article-slug>/ Output buffer callback
    10:53:40 /2010/01/<article-slug>/ Anonymous user detected. Only creating Supercache file.

    The problem is that the user wasn't anonymous. What could be going wrong?

  15. Donncha O Caoimh
    Plugin Author

    Posted 4 years ago #

    Something to do with cookies? Have you messed with them? There's a function in wp-cache-phase1.php that checks the COOKIE array. Maybe debug that? Did the debug log report any cookie info found?

  16. Leirith
    Posted 4 years ago #

    Thank you for your response.

    I think it's something to do with the Facebook Connect plugin that's installed. It may not be setting the required cookies at the appropriate time when it handles logins. Their support isn't as great - they're not even on WordPress.org, but I've seen some user suggestions to use a WP Super Cache hook to set add cookies to be checked. I've been working on something to that effect since reading those comments. Apparently it's a common problem so hopefully I can work it out. In your experience are there any alternatives that are known to work with WP Super Cache?

  17. Leirith
    Posted 4 years ago #

    I've finished writing and testing the WP Super Cache plugin. So far over 3000 pages have been cached on the production sites and none of them show the logged in view, which is good news. The cookie to test for was of the form "fbc_<facebookAppID>" and I used the wp_cache_get_cookies_values hook to add it.

  18. dspilka
    Posted 4 years ago #

    Leirith, could you summarize your findings/solution? It sounds like your issue involved detecting a facebook plugin cookie? How did you narrow that down and what/where is the connection with WP Super Cache?

    I'm still having this issue as I reported earlier and had taken a break from debugging it. I'm not using the facebook plugin though, but perhaps it could also be cookie related? I'll have to have a look at the function in wp-cache-phase1.php that checks the COOKIE array.

  19. Leirith
    Posted 4 years ago #

    Hi dspilka,

    Initially I suspected the issue was purely related to the facebook plugin, but I then noticed the issue was reproducible for specific URLs on the site. I thought about how pages were being cached by WP Super Cache and discovered that the logged in view was being cached by WP Super Cache by searching in the supercache directory for files containing strings from the logged in view.

    I then wondered if the issue was related purely to WP Super Cache but I made a test installation without the facebook plugin and the issue wasn't occurring - so I installed the facebook plugin and the issue was back.

    I set about looking at how WP Super Cache was determining whether or not a user was logged in and found the function in wp-cache-phase1.php, there is a function called wp_cache_get_cookies_values(). It looks for three different cookie keys that WordPress sets when a user is logged in. I stepped through the code and found that when a user was logging in with facebook, those cookies were not being set right away. There was however a cookie that was being set at this stage, which was of the form fbs_<facebookAppID>.

    I found an article that described similar issues with a facebook plugin and WP Super Cache, and in that case it was solved by writing a plugin for WP Super Cache to check for an additional cookie key. The cookie key was different to the one my facebook plugin was setting, so I adapted the code from wp_cache_get_cookies_values() in wp-cache-phase1.php, added it to a plugin which hooks to wp_cache_get_cookies_values and placed it in the WP Super Cache plugins directory. Additionally, as a comment in wp_cache_get_cookies_values() suggested, I added the cookie to test for to the conditions in the .htaccess file in the WordPress root directory.

  20. Leirith
    Posted 4 years ago #

    Here's the code for the plugin.

    function fbconnect_patch_get_cookies_values($string) {
    	if (!isset($string))
    		$string = '';
    	while ($key = key($_COOKIE)) {
    		if ( preg_match( "/^fbs_/", $key ) ) {
    			if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Cookie detected: $key", 5 );
    			$string .= $_COOKIE[ $key ] . ",";
    	return $string;
    add_cacheaction('wp_cache_get_cookies_values', 'fbconnect_patch_get_cookies_values');

    Below is the line that I altered in .htaccess. It occurs twice in this file. As you can see I added the cookie prefix "fbs_" to the regular expression.

    RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress_logged_in|wp-postpass_|fbs_).*$

  21. Donncha O Caoimh
    Plugin Author

    Posted 4 years ago #

    Leirith - thanks for posting such a detailed response. Hopefully it'll help authors make their plugins compatible.

    Instead of editing the .htaccess you could use the "supercacherewriteconditions" filter to add the "fbs_" cookie fragment to the rewrite_rules. Look for the filter in wp-cache.php and you'll see the rules are passed to it in one big string (lines separated by carriage returns)

  22. Pete_PT
    Posted 4 years ago #

    Thanks Leirith,

    Could you just explain, please, the steps to create this plugin.

    DO I just create a php file in the wp-content/plugins/wp-super-cache/plugins folder ?

    with the above code in it?

    What should I call the file or is it up to me?

    I did these steps but there is no plugin showing on the wp supercache plugins page in settings.

    Did I miss a step?

    Many thanks

  23. Leirith
    Posted 4 years ago #

    Hi Pete,

    Yes, create the PHP file in the wp-content/plugins/wp-super-cache/plugins folder with the code I posted. You can call the file anything you like.

    Don't worry about it not showing up in the admin screen - it will still execute. I'm not sure how to add it to the admin screen actually. I can see there is a file that lists the other plugins but I haven't found any documentation for how to modify it. Perhaps it's something that donncha can clarify.

    I also added a filter for the rewrite rules as suggested by donncha. This code went in the same file.

    function fbconnect_patch_supercacherewriteconditions($condition_rules) {
        $condition_rules[] = "RewriteCond %{HTTP:Cookie} !^.*fbs_.*$";
        return $condition_rules;
    function fbconnect_patch_filters() {
        add_filter('supercacherewriteconditions', 'fbconnect_patch_supercacherewriteconditions');
    add_cacheaction( 'add_cacheaction', 'fbconnect_patch_filters' );

    Hope this helps.

  24. Pete_PT
    Posted 4 years ago #

    HI, I can't say that this is working either. If I log out, all other links are showing as logged out, except the home page!

    I even deleted the facebook like plugin.

    Can you suggest a troubleshooting procedure? I do appreciate your help. Having got allthe CDN stuff working with cnames, I feel I am so close to geting the sites running at the speed and functionality that I want.

    DO I still need to replace those htaccess lines?

  25. Donncha O Caoimh
    Plugin Author

    Posted 4 years ago #

    Check the readme.txt for the troubleshooting tips there, but the debug log the cache plugin generates will tell you loads. Also examine the cached files in the wp-content/cache/ directory. Look in wp-content/cache/supercache/ too. Are they logged in or out cached files?

  26. Pete_PT
    Posted 4 years ago #

    Thanks Donncha,

    The gzip file and normal cache file for homepage are the logged in versions.

    When I view source on a logged out home page, I still see the logged in page, and there is no supercache stamp at the bottom of the source.

    Debug on a hompage request followed by logout caused the following..

    17:13:31 / wp_cache_shutdown_callback: collecting meta data.<br />
    17:13:37 /wp-login.php?action=logout&redirect_to=peteluxford.com&_wpnonce=89f80ea9cd Cookie detected: wordpress_logged_in_6818ee256090c441ae0383ba20094c89<br />
    17:13:37 /wp-login.php?action=logout&redirect_to=peteluxford.com&_wpnonce=89f80ea9cd supercache dir: /home/sites/peteluxford.com/public_html/wp-content/cache/supercache/www.peteluxford.com/wp-login.php/<br />
    17:13:37 /wp-login.php?action=logout&redirect_to=peteluxford.com&_wpnonce=89f80ea9cd No wp-cache file exists. Must generate a new one.<br />
    17:13:39 /wp-login.php?action=logout&redirect_to=peteluxford.com&_wpnonce=89f80ea9cd Cookie detected: wordpress_logged_in_6818ee256090c441ae0383ba20094c89<br />
    17:13:39 /wp-login.php?action=logout&redirect_to=peteluxford.com&_wpnonce=89f80ea9cd In WP Cache Phase 2<br />
    17:13:39 /wp-login.php?action=logout&redirect_to=peteluxford.com&_wpnonce=89f80ea9cd Setting up WordPress actions</p>
    <p><br />17:13:39 /wp-login.php?action=logout&redirect_to=peteluxford.com&_wpnonce=89f80ea9cd Supercache caching disabled. Only using wp-cache. Non empty GET request.<br />
    17:13:39 /wp-login.php?action=logout&redirect_to=peteluxford.com&_wpnonce=89f80ea9cd URI rejected. Not Caching</p><br />
    <p>17:13:40 /peteluxford.com supercache dir: /home/sites/peteluxford.com/public_html/wp-content/cache/supercache/www.peteluxford.com/peteluxford.com/<br />
    17:13:40 /peteluxford.com No wp-cache file exists. Must generate a new one.<br />
    17:13:41 /peteluxford.com In WP Cache Phase 2<br />
    17:13:41 /peteluxford.com Setting up WordPress actions<br />
    17:13:41 /peteluxford.com Created output buffer<br />
    17:13:41 /peteluxford.com Output buffer callback</p>
    <p><br />17:13:41 /peteluxford.com Buffer is blank. Output buffer may have been corrupted by another plugin or this is a redirected URL. Look for text 'ob_start' in the files of your plugins directory.<br />
    17:13:41 /peteluxford.com No closing html tag. Not caching.<br /></p>
    <p>17:13:41 /peteluxford.com wp_cache_shutdown_callback: collecting meta data.<br />
    17:15:50 /wp-admin/admin-ajax.php In WP Cache Phase 2<br />
    17:15:50 /wp-admin/admin-ajax.php Setting up WordPress actions<br />

    Is that the problem in bold?

  27. Pete_PT
    Posted 4 years ago #

    I have found that as soon as I clear my Browser cache and refresh the page in question it immediately loads the supercache file.

    Is there a way to stop my browser caching just my site?

  28. Oliver Krautscheid (oliversk)
    Posted 4 years ago #

    I had the exact same problem. It was caching me as logged in. After reading this I figured it is related to the comments form.

    Maybe you want to create a list of plugins that are incompatible?
    Here's the one that does not work for whatever reason:
    - growmap-anti-spambot-plugin

    Other problems I found recently
    When you deactive Superache and get the message you need to remove WP_CACHE it will display that message even after removing it. Strange!

    Another problem, the entire site breaks when you have an invalid wp-cache-config.php or if you copy the sample config into wp-content. Could be fixed in 1.0?

    And another problem is the mfunc tag does not always work with Late-Init in .. but I need to look into it don't know how to reproduce the bug.

  29. Donncha O Caoimh
    Plugin Author

    Posted 4 years ago #

    Pete_PT - check the cacheability of your site using http://redbot.org/ - that will tell you how anonymous browsers see your site.

    You could try editing wp-content/cache/.htaccess and changing the "max-age" to 0 or a smaller number than the default 300.

    sOliver - it's probably better if you post a message to that plugin's forum saying the plugin isn't compatible with supercaching. Hopefully the author will fix it if possible. If it doesn't work with this caching plugin it probably won't work with others.

    The WP_CACHE warning is I think because the wp-config.php on your server wasn't writeable. Thanks.

    What error did you see when you tried to use the sample config file? Unfortunately the config file is loaded by every page served so if it's broken then the site will break. Did the plugin break it or were you editing it by hand?

  30. Pete_PT
    Posted 4 years ago #

    Again thank you.

    HTTP/1.1 200 OK
        Date: Fri, 11 Mar 2011 08:09:46 GMT
        Server: Apache/2
        Last-Modified: Thu, 10 Mar 2011 14:40:59 GMT
        Accept-Ranges: bytes
        Content-Length: 8563
        Cache-Control: private, pre-check=0, post-check=0, max-age=0
        Expires: 0
        Vary: Accept-Encoding,Cookie
        Pragma: no-cache
        Keep-Alive: timeout=15, max=100
        Connection: Keep-Alive
        Content-Type: text/html; charset=UTF-8
        Content-Encoding: gzip

    It's still cacheing in my browser though. Have to say this is driving me mental :) When I log in, it only seems to cache some of the logged in pages. So when I log out, some pages are logged in versions others aren't!

    Am going to disable all plugins again and re-activate one by one again, using two computers to see what is caching externally.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WP Super Cache
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic