The Builtin Storage Backend uses request_uri() to construct the Cache ID. The URI may also contain query keys which are not relevant for caching. For example utm_* keys for GA tracking.

I have seen code where the desire to prevent these keys from invalidating the cache, made the developer alter the $_SERVER['REQUEST_URI'] (ouch!). Alternatively they could have hacked or forked the Builtin Storage Backend module (not desirable either). Ideally the Builtin Storage Backend provides a method to alter the final information that is used for the cache ID. For example a hook_authcache_buildin_cid_alter() or hook_authcache_buildin_uri_alter().

Comments

Sutharsan created an issue. See original summary.

znerol’s picture

Regrettably it is not safe to invoke any custom hooks before Drupal is bootstrapped fully. I also do not know a way to cleanly extend the list of hard-coded bootstrap_hooks which are safe to be called early.

Instead of altering the $_SERVER['REQUEST_URI'] one might want to rewrite the request URL directly in the webserver, the reverse proxy or via .htaccess. This is also inline with common Varnish configurations where you just remove any frontend-only cookies.

sutharsan’s picture

Ah, I did not think about the bootstrap phase, of course.
Another possibility: a variable defined callback. Just like authcache_backend_anonymous_key() uses.

Or what about an OO approach by converting the backend to a class and using a variable to provide the name of the backend class. Then modifying the request uri provider is a matter of extending the class and overriding a method. Like a service override in D8. (not too seriously, I know this won't happen)

znerol’s picture

This is a very slippery slope. It is one thing to allow altering the request path and parameters. But it is a completely different thing to allow site builders to alter the cid in any random way. During the development of Drupal 8 some very hard to resolve issues were introduced because core contributors ignored page caching when adding new features (e.g., #2364011: [meta] External caches mix up response formats on URLs where content negotiation is in use).

I do not intend to add such a dangerous feature unless there is a major benefit for many authcache users.

znerol’s picture

Status: Active » Closed (won't fix)

Closing this. Please reopen if anyone has a workable and safe solution to this.