Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authenticated users getting cached pages #18

Closed
addisj opened this issue Jan 6, 2012 · 7 comments
Closed

Authenticated users getting cached pages #18

addisj opened this issue Jan 6, 2012 · 7 comments
Assignees

Comments

@addisj
Copy link

addisj commented Jan 6, 2012

My apologies if this is the wrong place for this issue, but using centos5.6+nginx0.8.4+php-fpm+drupal7+boost with the drupal_boost config, authenticated users are being served the cached versions of the page.

The only modification I have made to the stock config is applying this patch [https://github.com//issues/14] to the beginning of map_cache.conf to allow caching of the homepage.

I have also read through this discussion [http://www.ruby-forum.com/topic/3302927] and tried the suggestions in the 2nd post, but it made no difference.

If it helps the available cookies are:
has_js=1; __utma=16729588.1676405263.1325874996.1325874996.1325874996.1; __utmb=16729588.11.10.1325874996; __utmc=16729588; __utmz=16729588.1325874996.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); SESS0b787746165e40414fa69ee6aa29f572=vCI9hDndfAoEjLj7xs0KI5H0i2u_OvrzpQJJlDJOBRo; DRUPAL_UID=1; Drupal.toolbar.collapsed=0

Thanks for any help.

@ghost ghost assigned perusio Jan 7, 2012
@perusio
Copy link
Owner

perusio commented Jan 7, 2012

Hello,

Can you please add the following code to your config at the server level:

sub_filter '</html>' "<p>no_cookie: $no_cookie</p></html>";

and check the value printed? It should be 1 for authenticated users. Note that you must have the http sub module compiled in. Check nginx -V for --with-http_sub_module.

Thanks,

@addisj
Copy link
Author

addisj commented Jan 7, 2012

Thanks for the reply perusio! I do have the http_sub module compiled in.

I'm assuming you meant to output the $no_cache variable, there was an error trying to use $no_cookie. I also included the $http_cookie variable for reference.

no_cache: 0
http_cookie: has_js=1; __utma=16729588.1494121925.1325947904.1325947904.1325947904.1; __utmb=16729588.8.10.1325947904; __utmc=16729588; __utmz=16729588.1325947904.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); SESS0b787746165e40414fa69ee6aa29f572=KxMtDpkpniNqnirM54dnMY48gNwLvXC06RRgkstQxfI; DRUPAL_UID=1; Drupal.toolbar.collapsed=0

And here is my map_cache.conf:

map $request_method $no_cache {
default 0;
POST 1;
}

map $http_cookie $no_cache {
default 0;
~SESS 1;
}

map $request_uri $is_index {
default 0;
/index.php 1;
/ 1;
}

The only way I could get this to work was to add a check for the SESS cookie after the if($no_cache) line.

if ($no_cache) {
return 418; # I'm a teapot/I can't get no cachifaction
}
// Added
if ( $http_cookie ~ "SESS" ) {
rewrite ^/(.+)$ /index.php?q=$1 last;
}

@perusio
Copy link
Owner

perusio commented Jan 8, 2012

Hmm, that's strange. Apparently your map is not setting $no_cookie as it should. If this is D7 there's no need for a rewrite. I'm going to update the config tomorrow, so I'll test Boost again on D7. In the meantime replace your rewrite with:

if ($http_cookie ~ SESS) {
   return 418;
}  

@addisj
Copy link
Author

addisj commented Jan 9, 2012

Ok thanks.

I replaced the rewrite with 'return 418;' and all pages are working correctly except for the homepage, which returns a blank white screen.

I'll wait to see what you find while testing.

@perusio
Copy link
Owner

perusio commented Jan 9, 2012

I've pushed a new config and I tested the frontpage cache. Try it out and report back.

@addisj
Copy link
Author

addisj commented Jan 9, 2012

The new config works great, thanks!

I'm still experiencing the map $http_cookie $no_cache bug from above, but now adding:

if ($http_cookie ~ SESS) {
return 418;
}

as you suggested earlier works perfectly.

Thanks again!

@perusio
Copy link
Owner

perusio commented Jan 9, 2012

That's strange. It should work. But hey it works now: the frontal page caching. That's good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants