I've got everything working well with authcache and the expires module to enable a high minimum cache life. Everything works fine when logged in, however the cache doesn't seem to expire for anonymous users, even with a hard refresh until the session is cleared (like opening a new Chrome incognito window or clearing cookies).

I can see that the page is being sent via the cache in the headers response is getting hit. Why would the cache get cleared from the logged in user but not the anonymous one. I'm using boost as well, but can see the page is being served by the internal cache since the boost header isn't being set, so that's not the issue.

This also only seems to happen on my production server and not locally even running the same database/configuration.

Any ideas? Does it have something to do with the key lifetime? I'm confused as to what that setting means.

Thanks

Comments

znerol’s picture

Which version of the Expire-module do you use?

atracht’s picture

I was using 2x stable, tried 2x dev and same issue. Something I did find though is if I open another browser without that session cookie already set it clears the cache so that the anonymous page that wasn't clearing in the original browser actually refreshes.

Edit: Did some more testing and can confirm, anonymous authcache pages will not expire unless another session by another user or browser without the cached page or cookie refreshes the page. Weird.

znerol’s picture

Can you test whether this is a browser cache issue? Steps you could take to disable the browser cache:

  1. Disable the cache in the browser (many browsers have that option in the developer tools)
  2. Navigate to Administration » Configuration » Development » Performance and set Expiration of cached pages to none
atracht’s picture

I disabled both browser cache and cookies. Here are the steps to reproduce

(Logged out browser) Visit content page to generate cached version
(Logged in browser) Edit piece of content.
(Logged in browser) Content cache cleared properly for logged in user.
(Logged out browser) Refresh the page, old content is shown, refresh after refresh.

After opening a third browser anonymous session the page refreshes correctly.
Now going back to the original logged out browser and hitting refresh now causes the page to show the updated version.

znerol’s picture

Can you test whether this has something todo with the minimum cache lifetime? Navigate to Administration » Configuration » Development » Performance and set Minimum cache lifetime to none.

Does it have something to do with the key lifetime? I'm confused as to what that setting means.

The Authcache Builtin Storage Backend uses a cache to memoize which session (session-id) is associated with which authcache key (hash of role-combination). The key is used to select which variant is retrieved from the cache. The key lifetime specifies for how long this information should be stored. I do not think that this is causing the issue at hand.

atracht’s picture

After testing, setting minimum cache lifetime to 0 fixes this. The page is updated and then served cached afterwards in contrast to requiring clearing the browser setting and manually refreshing when it's set to 6 hours for example.

So perhaps this is an issue with the expires module although it appears to be doing its job for logged in users. It's setup correctly using external expiration. Looking at at return headers, it's set to no-cache as well.

znerol’s picture

The fact that this works for authenticated users but not for anonymous makes me think that there is something wrong with Authcache Builtin Cache Expiration v2 module.

Can you set a breakpoint somewhere around line number 30 of authcache_builtin_expire_v2.module and examine whether the contents of $cids / $wildcard_cids are reasonable when the expire hook is fired? There have been issues with expire removing aliases instead of system paths or vice versa in the past, so that might be a scenario to consider.

Also if you specified a custom key generator for anonymous users via $conf['authcache_key_generator'] in settings.php, that might be a problem.

atracht’s picture

It looks correct, dumping $cids

array(105) { [0]=> string(8) "d71a416/" [1]=> string(23) "d71a416/node/14449/edit" [2]=> string(13) "d71a416/front" [3]=> string(18) "d71a416/node/14449" ...

What tables correspond to the $cids, that contain the cached pages?

znerol’s picture

array(105) { [0]=> string(8) "d71a416/" [1]=> string(23) "d71a416/node/14449/edit" [2]=> string(13) "d71a416/front" [3]=> string(18) "d71a416/node/14449" ...

Do you also see entries of the form $base_url/path (e.g. http://example.com/node/X)?

What tables correspond to the $cids, that contain the cached pages?

cache_page.

atracht’s picture

I think I figured out the issue which may or may not be related to authcache. Logged in the site is run in https so expires (in the array dump) only clears https urls which aren't used for anonymous users. Any ideas?

znerol’s picture

Congratulations, and thanks for tracking that down. This also nicely explains the difference between localhost and production.

If I'm not mistaken, you can override the base URLs used to generate the cids for anonymous users by adding the following fragment to settings.php:

$conf['authcache_key_generator_keys'] = array(
  'http://example.com',
  'https://example.com',
);

Note, $base_url has no trailing slash.

I think I'll want to support that out of the box. However, I probably need some time to figure out how.

Update: Pointed the documentation at this comment, this should do it for now.

atracht’s picture

Still seeing the issue. When the page gets cached the only $cid that appears is the actual url (aliased and with http). I've disabled https for now to troubleshoot. Expires doesn't seem to be triggering since the $cid remains and the only way to force refresh is to delete the cache entry manually.

atracht’s picture

I've finally gotten it to work. With https disabled, both anonymous and logged in pages clear if I define the base url in the generator keys. Shouldn't these be included by default?

$conf['authcache_key_generator_keys'] = array(
  'http://example.com',
);
znerol’s picture

Yes, they should be included by default.

znerol’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.