• Resolved doconeill

    (@doconeill)


    I’ve run into a few issues with the caching done with WP-FFPC – although I’m not sure if there are solutions…

    Of course I had to redo my rotating ads that were previously generated by PHP inline, and instead use a javascript method.

    But I have two themes, one of which is used automatically by mobile browsers. It seems that if a page is visited by a mobile browser first, it will cache that page and serve it to non-mobile browsers as well. Is there any way to disable caching on a per-theme basis?

    Second, if I am also using nginx and try to use the memcached cache directly, when I access individual post pages as a logged-in user, it renders it as if I’m not logged in – my guess is having nginx using the cache bypasses any options that are set in WP-FFPC and serves up whatever page is cached regardless if I’m logged in. This could be very bad if I allowed it to cache pages for logged in users, as the users might not get the logged-in version of the page, and conversely non-logged-in users might get the logged-in version of the page. This makes it unsuitable for sites that have general users.

    https://www.ads-software.com/extend/plugins/wp-ffpc/

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author petermolnar

    (@cadeyrn)

    Hi doconeill,

    First problem: if there’s no info on the theme in the URL right now I don’t think there’s a way to solve this. I’m going to think about the topic.

    Second problem: if the logged-in pages could be identified by and URL pattern, you could add an exception to nginx, but since nginx is unable to analyze content normally, without a “hacked” nginx, it’s not possibile to diverse this way.
    I’ll look deeper how to check for a cookie from nginx, this might solve it.

    Plugin Author petermolnar

    (@cadeyrn)

    Ho doconeill,

    I’ve extended the nginx part, I’ll test it this week as soon as possible. For the different theme layout, I’d recommend setting up a cookie and somehow insert it into the rewrite uri sent to wordpress.
    For tips see this post:
    https://nicknotfound.com/2009/01/12/iphone-website-with-nginx/

    Thread Starter doconeill

    (@doconeill)

    Thanks for looking in to it. The performance boost by bypassing PHP was nice, but not necessary at the moment. I may need to re-architect for the mobile issue…

    Plugin Author petermolnar

    (@cadeyrn)

    Hi @doconeill,

    I’ve been testing and appending the nginx sample conf; it seems that serving with nginx from memcached directly can now be used without problems using the following:

    upstream memcached-server {
            server MEMCACHEDHOST:MEMCACHEDPORT;
            keepalive 32;
    }
    
    ...
    server {
    	...
    
    	location @memcached {
    		default_type text/html;
    		set $memcached_key DATAPREFIX$scheme://$host$request_uri;
    		set $memcached_request 1;
    
    		# exceptions
    		# avoid cache serve of POST requests
    		if ($request_method = POST ) {
    			set $memcached_request 0;
    		}
    
    		# avoid cache serve of wp-admin-like pages, starting with "wp-"
    		if ( $uri ~ "/wp-" ) {
    			set $memcached_request 0;
    		}
    
    		# avoid comment sync caching used for disqus plugin usually
    		if ( $uri ~* "sync_comments" ) {
    			set $memcached_request 0;
    		}
    
    		# avoid cache for logged in users
    		if ($http_cookie ~* "comment_author_|wordpressuser_|wp-postpass_" ) {
    			set $memcached_request 0;
    		}
    
    		if ( $memcached_request = 1) {
    			more_set_headers 'X-Cache-Engine: nginx ( with WP-FFPC )';
    			memcached_pass memcached-server;
    			error_page 404 = @rewrites;
    		}
    
    		if ( $memcached_request = 0) {
    			rewrite ^ /index.php$request_uri last;
    		}
    	}
    
    	## rewrite rules
    	location @rewrites {
    		rewrite ^ /index.php$request_uri last;
    	}
    
    	location / {
    		try_files $uri $uri/ @memcached;
    	}
    
    	...
    }
    ...

    replace DATAPREFIX with your data prefix set on options page ( default: data- )
    replace MEMCACHEDHOST with your memcached host IP ( default: 127.0.0.1 )
    replace MEMCACHEDPORT with your memcached server port ( default: 11211 )

    This is going to be part of the next release but I need other stuff to be changed as well, so consider this as pre-release ??

    For the theme problem: you could change the key in the PHP code and the memcached config to include something else as well, depending on a cookie entry existenz for example, but I haven’t figured out anything else yet.

    Thread Starter doconeill

    (@doconeill)

    Thanks…I’ll look into these changes and see how it works. Interestingly, I have another site I’ve been setting up and just started working on, and had the old nginx memcached code still active – but I don’t seem to have the same problem with it. Not sure why.

    Thread Starter doconeill

    (@doconeill)

    Figured out why I wasn’t seeing the problem on the other site – misconfigured the cache ??

    This seems to work – after I figured out that a cut-and-paste turned the quotes into entities…also I had to skip more_set_headers for now as I don’t have that module compiled in yet.

    Thanks for the help!

    Thread Starter doconeill

    (@doconeill)

    Hmm…spent some time looking at this more closely. Although the cache appears to be working, I’m not sure that nginx is using the memcached directly.

    I added the module so that I could use more_set_headers, but the header in the config above doesn’t show up. I can put one outside the “location = @memcached” section, and it shows up. If I put it as the first thing inside the section, however, it doesn’t. So it appears that the request is never actually making it to the @memcached section.

    I haven’t tracked down why it doesn’t seem to to check it yet. I even put a more_set_headers in the “location /” section, and it doesn’t show up either. But I’m relatively new to nginx and having fun with location specs…here are the only ones I have on the site I’m testing with:

    location / {
    
    location @rewrites {
    
    location @memcached {
    
    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
    
    location ~ /wp-admin/.*\.php$ {
    
    location ~ /wp-admin/.*\.php$ { # This is to be able to have unbuffered output while updating plugins, wordpress, etc.
    
    location ~ \.php$ {
    
    location ~* /(?:uploads|files)/.*\.php$ {
    
    location ~ /\.ht {

    So I’m not sure why it won’t follow the “location /”…

    Plugin Author petermolnar

    (@cadeyrn)

    Hi,

    I’ve tried reproducing the bug, but I’m unable to do so.
    Do you have any update on the topic?

    Thread Starter doconeill

    (@doconeill)

    I was never able to get nginx to use the cache directly. Since then I’ve had to abandon nginx due to a number of unrelated issues getting some sites to work, and have gone back to Apache. Still using it on the PHP side though.

    Plugin Author petermolnar

    (@cadeyrn)

    Sad to hear you’re not on nginx anymore, anyway, feel free to get back to me whenever you change your mind.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Issues with cached pages’ is closed to new replies.