This is just a heads up issue that I made this core patch due to authcache_builtin_expire_v2_expire_cache() + locale #2507795: Improve performance l() function for multilingual sites and cache clear.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

znerol’s picture

i'm not 100% sure but maybe we could get rid of the url call completely. It looks to me like the only thing it is supposed to do is to prepend the (non-locale) url prefix.

Do you happen to know whether the expire module expands an url into all its language variants?

joelpittet’s picture

@znerol I don't think expire module expands it into all variants.

ExpireAPI::processInternalPaths() takes in a $langcode for "Language code of object that is expiring."

That would be cool if we didn't need to call url() though I think my patch still stands on it's own as url() could get called a lot and should scale nicer.

joelpittet’s picture

I'm chipping away at this slowly but surely!

One thing I noticed that is along the lines of what you were suggesting in removing the url() call completely:

$wildcards comes in with no language prefix! but url() generates things like this:

path: "admin/config/content/formats/%"
url: "/us/admin/config/content/formats/%25"

And the wildcard it's trying to match against is this:
"admin/config/content/formats/%"

In my case all those keys are false... so it doesn't matter but it's still wrong. I guess that's a different issue we should look into why they are all false and if that is legit.

Possible quick win:

One quick win here may be to just bail early if the bin is already empty?

if (cache_is_empty('cache_page')) {
  return;
}
joelpittet’s picture

Actual CID samples:

Anonymous:

http://site.dev/ca
http://site.dev/ca/company-overview
http://site.dev/us/company-overview

Admin:

39cb994/ca/admin/config/content/formats/
39cb994/ca/admin/config/content/formats/full_html
21f93cc/us/admin/config/content/formats/
a714259/ca
a714259/ca/admin/commerce
joelpittet’s picture

Status: Active » Needs review
FileSize
3.02 KB

Here's a possible solution... though not sure if it's the best...

Also since I gutted url() function I wonder if it would still work with domain based locale instead of prefixed like mine.

das-peter’s picture

@joelpittet Thanks for the hint! I've just added locale support to following authcache integration: http://cgit.drupalcode.org/enhanced_page_cache/tree/enhanced_page_cache....
And indeed it is crazy! Now url() isn't just requested for every path put also for every language with a language prefix.

znerol’s picture

@das-peter: What about moving that into Authcache Enum? In fact your code looks a lot like #2543352-9: Unable to alter authcache_enum user key generation input..

das-peter’s picture

@znerol Hmm, I don't think this code belongs to enum, because to me it seems like enums solely purpose is to generate keys that are related to the identification of user specific cache ids - with the only exception of anonymous users which share a "key". So for me the code I wrote belongs more to authcache_builtin_expire_v1 / authcache_builtin_expire_v2 hook_expire_cache(). I actually wanted to create patches for those modules but hadn't the time yet - since I focused on my own authcache integration in enhanced_page_cache.

znerol’s picture

Oh, I think the difference is that if you have domain based language negotiation, then Authcache Enum needs to compute all possible values of $base_root (because that is part of the key properties). In contrast when working with path prefixes, then that clearly belongs into the hook_expire_cache() implementation.

das-peter’s picture

Oh indeed, so I absolutely agree that the language domain handling belongs to enum - but not the path prefix.
Yay consensus - now we just need to get all the things done :)

joelpittet’s picture

I'd like to help but TBH a bit lost at the next steps... Can I do anything to this patch to make it more in line or is it ok as is?

das-peter’s picture

@joelpittet I just gave your code a test run and it looked fine, so I pushed it to the enhanced page cache repo: http://cgit.drupalcode.org/enhanced_page_cache/commit/?id=cca4be4a24f9a0...
I just found following nitpicks and fixed them there:

  1. +++ b/modules/authcache_builtin_expire_v2/authcache_builtin_expire_v2.module
    @@ -11,12 +11,17 @@
    +   //If the page cache is empty, no need to do any work.
    

    Space after // missing.

  2. I'm tempted to say RTBC - but I tested this just very roughly.

    +++ b/modules/authcache_builtin_expire_v2/authcache_builtin_expire_v2.module
    @@ -35,3 +40,54 @@ function authcache_builtin_expire_v2_expire_cache($urls, $wildcards, $object_typ
    +    'prefix' => ''
    

    A comma should follow the last multiline array item.

znerol’s picture

FileSize
62.32 KB
62.32 KB

I believe it is possible to get away without actually calling url() at all. The expire module already does that for us. The idea here is:

  1. Ensure that the expire module generates full URLs (including the base URL, see screenshot).
  2. Remove the URL scheme, host and port and only work with path, query fragment when computing the permutations.

Do you think that this might be a viable solution?

znerol’s picture

FileSize
993 bytes

Forgot the patch.

joelpittet’s picture

Something wrong with the testbot or branch tests? I had to tag a new release in commerce_discount to make testbot smarten up. FYI #2490991: Tests pass locally and not on testbot: commerce_discount

Edit: Oh the branch failed some tests that's why:
https://qa.drupal.org/pifr/test/512338

joelpittet’s picture

@znerol #14 throws a bunch of

Warning: parse_url() expects parameter 1 to be string, array given in authcache_builtin_expire_v2_expire_cache() (line 19 of authcache/modules/authcache_builtin_expire_v2/authcache_builtin_expire_v2.module)

joelpittet’s picture

$urls seems to be coming in the form ['path' => ['path' => 'user/1', 'query' => '']] from expire.

But I've got the patch from #2267305: Problem when clearing the cache of nodes using entity translation applied and if $include_base_url is not TRUE, it will send the array across like that, hmm. Thoughts @das-peter?

joelpittet’s picture

My mistake, that patch doesn't change that it just makes it more aware of other languages. @znerol back to you.

Edit: and to answer it may only be a viable solution if $include_base_url is true. Which is a bit silly if you ask me that you would get an array in one case and a string in another:S

joelpittet’s picture

Issue summary: View changes
FileSize
66.67 KB

Here's an interesting but confusing UI... compared to what it does with respect to authcache.

znerol’s picture

@joelpittet: Do you run expire 7.x-2.x-dev? It seems to me that the array could be due to recent commits #1780144: Should expire.module urlencode urls. I cannot tell whether they intended to pass an array in some cases or whether that is a bug.

das-peter’s picture

I was wondering too why the heck one time it's an array and then a string again.
I'd say that should be unified :|
And if we want to have support for queries it might is smart to have an array - that way not all the modules would have to do a parse_url().

joelpittet’s picture

joelpittet’s picture

Ok resolved that weird array thing. Man the help text on base url inclusion likely need improvement on expire as well. I have to read that like 5-6 times before I grasp what it's trying to say.

Anyways going to try #14

znerol’s picture

@joelpittet do you think that #14 should be committed?

joelpittet’s picture

Status: Needs review » Reviewed & tested by the community
+++ b/modules/authcache_builtin_expire_v2/authcache_builtin_expire_v2.module
@@ -15,8 +15,15 @@ function authcache_builtin_expire_v2_expire_cache($urls, $wildcards, $object_typ
+        $cid .= '?' . $parts['query'];
...
+        $cid .= '#' . $parts['fragment'];

I've not had these scenarios yet but I've been using and testing with this patch and I think so yes.

  • znerol committed 7ef8ac5 on 7.x-2.x
    Issue #2507797 by znerol, joelpittet:...
znerol’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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