The Authcache Builtin Storage Backend integrates with the Cache Expiration module. This combination allows to selectively remove pages from the cache after a node is edited while a minimum cache lifetime is maintained for other pages.
The Authcache Enum module is responsible for calculating all the possible authcache keys, such that all variants of a page are cleared from the cache. This module currently does not calculate the keys correctly and therefore cache clearing for authenticated users currently does not work.
I think the attached patch should fix cache invalidation even when the site is not installed in the document root but within a subdirectory.
Comments
Comment #1
znerol CreditAttribution: znerol commentedThe attached patch should fix the issue.
Comment #2
znerol CreditAttribution: znerol commentedComment #3
znerol CreditAttribution: znerol commentedCommitted and pushed cf5bebb.
Comment #4
RAFA3L CreditAttribution: RAFA3L commentedI already test the last dev version (with the committed patch) and the problem continue, only clear the anonymous cache (same with files or database)
In the Expire module I try with Internal and External, the Node Expiration actions and Rules, and all with the same result
Comment #5
RAFA3L CreditAttribution: RAFA3L commentedI Think the problem is major, now I'm understanding a little more the module. I'm not an expert.
The module does not clear the cache at all, only is cleared by the Expire module when use the internal expiration option, and only the anonymous users cache.
If you put this:
dsm($cids);
at the end of authcache_builtin_expire_cache() and save some node can see that all the urls are bad formed and with the wrong key.
Tomorrow I'll continue...
Comment #6
RAFA3L CreditAttribution: RAFA3L commentedFinally I get it to work...
For some reason $properties_info in authcache_enum_user_keys() is not ordered properly, so I force it to the right order, I don't know if this is the best solution but works.
And the problem with the absolute urls maybe is in the Expire module side
https://drupal.org/node/2113941
I fix it with this
Comment #7
aheimlich@RAFA3L
Regarding your array ordering issue, I think adding a call to
ksort
at the beginning ofauthcache_user_key()
would solve that problem.Also,
authcache_enum_user_keys()
should probably detect whether the current is the superuser or not, likeauthcache_key()
does.Comment #8
znerol CreditAttribution: znerol commentedRe #6: It is necessary to configure the expire module such that the base URL is not included in the
$urls
parameter tohook_expire_cache()
. Navigate to Administration » Configuration » Development » Performance » Cache Expiration and disable the Option Include base URL in expires (see attached screenshot).Also please note the documentation introduced by commit 35602cf. I hope it clarifies the inner workings of
authcache_enum_user_keys()
and especially_authcache_enum_cartesian()
. If you wish to stay with your$tmp
-hack, you'd need to specify$tmp['ajax']
as an array, i.e.$temp['ajax'] = array(TRUE, FALSE);
.Re #7: Good catch, you are completely right about
ksort
and the unique key for superuser. The solution for the latter problem however probably needs some more attention. It is necessary thatauthcache_enum_user_keys()
always returns the same results, regardless of whether the superuser is logged in or not. The solution you are proposing will return the complete set of keys prepared for superuser whenuid=1
is logged in. When superuser is not logged in, it will also return the complete set of keys, however none of them prepared for superuser. An easy solution would be to simply document the fact that the superuser-feature is not compatible with expire for the moment and develop a proper solution when the need really arises.Comment #9
aheimlichI wasn't really planning on using the super-user feature anyway. I just wanted to point that out for consistency's sake.
Comment #10
znerol CreditAttribution: znerol commentedComment #11
RAFA3L CreditAttribution: RAFA3L commentedYou are right @znerol, I was using the 7.x-2.x-dev of the Expire module. But changing it to 7.x-1.0-beta1 or 7.x-1.x-dev (and applying the patch) doesn't fix the problem. My test site is in a subfolder "localhost/testcache" and with the "Include base URL in expires" disabled I get this cids in authcache_builtin_expire_cache, for example:
7371cb8/node/1
7371cb8/content/test-1
The subfolder is excluded.
And I notice that authcache_builtin_expire_cache get all the url nodes (with and without alias), so I think if the cids were right will clear all the pages cached and not only the updated.
The ksort call work perfect.
Comment #12
znerol CreditAttribution: znerol commented.
Ah, I see. That is actually the problem. The expire module actually passes the paths to hook implementations, therefore we need to add the contents of the $base_path variable to the URL. Patch attached.
Comment #13
RAFA3L CreditAttribution: RAFA3L commentedThe patch work using Expire 7.x-1.x-dev, but now clear all the cached pages and would be only the updated node and any other indicated in rules.
Using Expire 7.x-2.x-dev work fine, only pass the selected urls, but the problem is that the option "Include base URL in expires" was discarded , as is explained here...
https://drupal.org/node/2113941
Comment #14
znerol CreditAttribution: znerol commentedOk, thanks for pointing out the API incompatibilities. I think it is worthwhile to fix this the proper way and extract expire-support into two dedicated modules for Cache Expiration 7.x-1.x and 7.x-2.x respectively. That way we can cut back on requirements checking / soft dependencies and also properly support the new wildcard feature of Cache Expiration v2.
After applying the patch you need to enable one of the new modules, either Authcache Builtin Cache Expiration v1 or Authcache Builtin Cache Expiration v2.
Comment #15
RAFA3L CreditAttribution: RAFA3L commentedThanks! Only one more thing...
With this changes work perfect
Comment #16
znerol CreditAttribution: znerol commentedRe #15: The structure of the
$urls
parameter is different for expire 7.x-1.x and 7.x-2.x:In 7.x-1.x:
In 7.x-2.x:
Note that in 2.x the array keys contain the paths and the array values contain the full URL. In 1.x only the array values are supplied and there is a configuration option to switch between full URLs and internal paths (see #8).
I really would like to work with the internal paths and I want to avoid calling
str_replace
on full URLs. Probably the reason why some paths are still not purged with the patch in #14 is that url() replaces internal paths by their aliases by default. Let's disable this option (by supplying'alias' => TRUE
) and try again...Comment #17
RAFA3L CreditAttribution: RAFA3L commentedYes! you are right! I was using an action rule to clear the cache with
[node:url]
and this is the cause of the problem, using rules doesn't pass the right path in the array keys. Using the node actions in the settings of the Expire module (without rules) all work perfect!
Thanks!!!
Comment #18
znerol CreditAttribution: znerol commentedI just tested action rules and I observed that expiring cache entries using rules only works when internal paths are supplied (instead of full URLs). In order to clear a node it is necessary to specify it using its path
node/[node:nid]
instead of[node:url]
.Thanks @RAFA3L and @aheimlich for pointing out this issues and helping me resolve them. Committed and pushed: 9152d17.
Comment #19
znerol CreditAttribution: znerol commentedDocumentation on this feature can be found in a new page of the tuning guide. Contributions to the docs are very welcome as well.
Comment #21
RAFA3L CreditAttribution: RAFA3L commentedHello znerol is me again...
I'm playing with the Context Mobile Detect module and I think it work fine with Authcache, but again, the problem is clearing the cache after update a node.
For example, the generated cache file using Blackberry is
...^testcache^node^1%3Fdevice%3D1%26device_type%3Dblackberry
But after update a node the cache file for the specific device is not cleared. Would be nice make it to work with Context Mobile Detect.
Comment #22
znerol CreditAttribution: znerol commented@RAFA3L: Please open a new feature request.
Comment #23
znerol CreditAttribution: znerol commentedA heads up, there is still an issue with Expire 7.x-2.x: #2177265: Authcache Builtin Cache Expiration v2 does not work on pages with alias
Comment #24
Samlet9908 CreditAttribution: Samlet9908 commentedSorry but I'm using the the latest builds of both Authcache and Cache Expiration with Memcached as the cache backend. If I enable 'external expiration' in Cache Expiration, when editing a node, it gives me a blank screen and does not save the node. I'm using aliases.
Comment #25
znerol CreditAttribution: znerol commentedThis issue is closed, please open a new support request.