WordPress.org

Ready to get started?Download WordPress

Forums

WP-FFPC
[resolved] Issues with cached pages (11 posts)

  1. doconeill
    Member
    Posted 1 year ago #

    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.

    http://wordpress.org/extend/plugins/wp-ffpc/

  2. petermolnar
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  3. petermolnar
    Member
    Plugin Author

    Posted 1 year ago #

    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:
    http://nicknotfound.com/2009/01/12/iphone-website-with-nginx/

  4. doconeill
    Member
    Posted 1 year ago #

    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...

  5. petermolnar
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  6. doconeill
    Member
    Posted 1 year ago #

    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.

  7. doconeill
    Member
    Posted 1 year ago #

    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!

  8. doconeill
    Member
    Posted 1 year ago #

    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 /"...

  9. petermolnar
    Member
    Plugin Author

    Posted 1 year ago #

    Hi,

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

  10. doconeill
    Member
    Posted 1 year ago #

    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.

  11. petermolnar
    Member
    Plugin Author

    Posted 1 year ago #

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

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic