Problem/Motivation

I'm attempting to use CDN to produce URLs for static assets that will change when those static assets change.
My site is also using the Redirect module, with its canonical URL redirection enabled, so that requests for node/123 get redirected to content/title etc.
I also have languages enabled on the site. So that in fact, if someone requested //fqdn/node/123 it'll actually get redirected to: //fqdn/en/content/title.

When enabling the CDN module, with farfuture, all of the files served no longer work since they are for paths like:
//fqdn/cdn/farfuture/3d8UFbZKlGF89ZdOA-ZpIxKK8s7YZImp7zXZXcBMiDs/1479386946/themes/custom/theme_name/favicon.ico
which redirect module will intercept and redirect to:
//fqdn/en/cdn/farfuture/3d8UFbZKlGF89ZdOA-ZpIxKK8s7YZImp7zXZXcBMiDs/1479386946/themes/custom/theme_name/favicon.ico

and then the security token is invalid.

Proposed resolution

I'm not sure! I feel like either:

  • the CDN paths needs declaring in such a way that it won't get tweaked for language prefixes etc.
  • the URL that CDN module outputs should run through that system and be altered accordingly
  • that the route should be flagged in such a way that redirect module won't touch it
  • The security token should be valid if the bit that was actually hashed matches, essentially ignoring prefixes.

Remaining tasks

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
#3 2924916-3.patch696 bytesWim Leers
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Steven Jones created an issue. See original summary.

Steven Jones’s picture

To skip the redirect normalizing, we could _disable_route_normalizer as described by RouteNormalizerRequestSubscriber.

http://cgit.drupalcode.org/redirect/tree/src/EventSubscriber/RouteNormal...

It looks like this route normalized might end up in core in #2641118: Route normalizer: Global Redirect in core

Wim Leers’s picture

Title: Incompatibility with redirect + language » Compatibility with contrib Redirect module: disable language redirects for CDN's "farfuture" route
Category: Bug report » Feature request
Status: Active » Needs review
Related issues: +#2641118: Route normalizer: Global Redirect in core, +#2877055: Disable route normalizer on remote image style routes to avoid problems with redirect module
FileSize
696 bytes

I'm attempting to use CDN to produce URLs for static assets that will change when those static assets change.

That's exactly what the Forever cacheable files feature is for, so yay! 🎉

The security token should be valid if the bit that was actually hashed matches, essentially ignoring prefixes.

the URL that CDN module outputs should run through that system and be altered accordingly

If we'd do that, then the Redirect module would still end up redirecting, which would be a performance regression.

the CDN paths needs declaring in such a way that it won't get tweaked for language prefixes etc.

This I strongly agree with: we should be able to flag routes as being language-agnostic. But, there's no mechanism for this (AFAICT).

that the route should be flagged in such a way that redirect module won't touch it

So this is then the best (and only) solution. You also gave super helpful pointers in #2, thanks! 👏

Since \Drupal\redirect\Routing\RouteSubscriber does exactly the same for the routes generating image style URLs, I think adding the _disable_route_normalizer route option is indeed the right thing to do. #2877055: Disable route normalizer on remote image style routes to avoid problems with redirect module is doing the same for another contrib module.
Patch attached for this!

Finally, a nitpick: this cannot be a bug, since it's integration with a contrib module. Only after #2641118: Route normalizer: Global Redirect in core lands, this could possibly qualify as a bug.

Steven Jones’s picture

Status: Needs review » Reviewed & tested by the community

Lovely! Didn't know that the route defaults would end up as request attributes, that's cool!

Works for me :)

Wim Leers’s picture

Did you manually test it, and confirm that it solves the problem? :)

Wim Leers’s picture

Issue tags: +Needs manual testing
Steven Jones’s picture

Sorry yeah, I got my site setup with all the right code, but no patch, tested, and it was broken as per the issue summary.
Applied the patch, rebuilt the container (and router) and then the issue was fixed!

Wim Leers’s picture

Issue tags: -Needs manual testing

👌

Credited you!

Wim Leers’s picture

Status: Reviewed & tested by the community » Fixed

Thank you!

Status: Fixed » Closed (fixed)

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