Hello, i've added CDN module with Amazon CloudFront and I tried to do some performance tests.

Tools.pingdom.com give me a bad score, because the following seo problem have appeared:

Minimize redirects
All static resouce now use a redirects, like www.mydomain.com/image.png to www.cdn.mydomain.com/image.png

Can this seo problem(if it is) reduce the benefits that i receive from a CDN performance boost ?

CommentFileSizeAuthor
#23 2874178-22-D7.patch1.02 KBWim Leers
#22 2874178-22.patch1.02 KBWim Leers
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Anonymous’s picture

hanser created an issue. See original summary.

Wim Leers’s picture

Status: Active » Postponed (maintainer needs more info)

The question is: what is pointing to www.mydomain.com/image.png? That is the real problem.

It's good that /image.png is redirected from origin to the CDN: it prevents duplicate content problems.

However, it's bad that your site is pointing to the file on origin instead of on the CDN.


It's extremely likely that your theme has a template with a hardcoded URL, which should be using the file_create_url() API call.

Anonymous’s picture

Status: Postponed (maintainer needs more info) » Active

The module redirects all images.
From how i could see in the network traffic analyzation i see all elements like this:

GET image.png 301 Moved Permanently cdn.mysite.com
GET image.png 304 Not Modified mysite.com

So the images will loaded two times...

I use Apache and CloudFront cdn with Origin Pull.

Edit: if i try to enable "Far Future expiration" with .htaccess modifications, all images in my site are not loaded at all, and i see
GET image.png 301 Moved Permanently cdn.mysite.com
GET image.png 403 Forbidden mysite.com

Anonymous’s picture

Priority: Normal » Major
Wim Leers’s picture

Priority: Major » Normal
Status: Active » Postponed (maintainer needs more info)

You didn't answer my question.

Anonymous’s picture

Thanks for your reply Wim Leers.

The question is: what is pointing to www.mydomain.com/image.png? That is the real problem.
I didn't understand the question, how do i check this?

Wim Leers’s picture

Where in the HTML does it point to that file?

Anonymous’s picture

Never, if i search for the specified image in the html i only receive one element that point to the cdn.
<img src="http://www.cdn.mydomain.com/image.png">

Wim Leers’s picture

If #8 is true, then this

All static resouce now use a redirects, like www.mydomain.com/image.png to www.cdn.mydomain.com/image.png

does not make any sense.

Anonymous’s picture

Yeah, but tools.pingdom.com give me multiple of these:

Minimize redirects
Remove the following redirect chain if possible:
http://cdn.mydomain.com/image.png
http://www.mydomain.com/image.png

and in the firefox network monitoring i see multiple of these:

GET image.png 301 Moved Permanently cdn.mydomain.com
GET image.png 304 Not Modified mydomain.com

So... is this a normal behavior of this module if inspected with this tool and network monitoring ?

Wim Leers’s picture

No, and I still don't understand how you're getting this problem, because you still haven't answered my questions fully.

I guess the next step is to ask you to post screenshots of what these tools are showing you. Hopefully I can make sense of this then.

Anonymous’s picture

Thanks.

Ok i've finally fixed this issue(and not only this) by forwarding the ?itok security token in the CDN, that was introduced after drupal 7.20.
https://www.drupal.org/drupal-7.20-release-notes

I think that we need to add this in the documentation, because not all cdn services can forward the query urls, and in this case we need to completely disable them to make drupal able to work with cdn and images.

$conf['image_suppress_itok_output'] = TRUE;
$conf['image_allow_insecure_derivatives'] = TRUE;

(with all security risks)

Anonymous’s picture

Status: Postponed (maintainer needs more info) » Active
Anonymous’s picture

Component: Miscellaneous » Documentation
Category: Support request » Feature request
Anonymous’s picture

Issue summary: View changes
Wim Leers’s picture

Category: Feature request » Support request

I think that we need to add this in the documentation, because not all cdn services can forward the query urls, and in this case we need to completely disable them to make drupal able to work with cdn and images.

I've yet to see one that does not. All CDNs I know of do this by default IIRC. Which CDN are you using?

I think that we need to add this in the documentation, because not all cdn services can forward the query urls, and in this case we need to completely disable them to make drupal able to work with cdn and images.

$conf['image_suppress_itok_output'] = TRUE;
$conf['image_allow_insecure_derivatives'] = TRUE;

(with all security risks)

As much as I hate ?itok=…, that's a dangerous recommendation.

Anonymous’s picture

I've yet to see one that does not. All CDNs I know of do this by default IIRC. Which CDN are you using?

Hi Win, i use Amazon CloudFront and query forwarding is not enabled by default, but can do it easily.

...but i think that some others or "custom" cdn may not do this easily.
I had trouble for some days to understanding that CloudFront need this settings for work with drupal.

As much as I hate ?itok=…, that's a dangerous recommendation.

Yeah, it's true, i just mentioned it for completeness of information.

Wim Leers’s picture

Title: Multiple redirect chain issue » Update README to warn that when using Amazon CloudFront, query forwarding
Wim Leers’s picture

Title: Update README to warn that when using Amazon CloudFront, query forwarding » Update README to warn that when using Amazon CloudFront, query forwarding must be enabled
Wim Leers’s picture

Version: 7.x-2.9 » 8.x-3.0
Category: Support request » Task
Issue tags: +Needs backport to D7

This also affects the Drupal 8 version of the CDN module.

Wim Leers’s picture

Version: 8.x-3.0 » 8.x-3.x-dev
Wim Leers’s picture

Status: Active » Needs review
FileSize
1.02 KB
Wim Leers’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs backport to D7
FileSize
1.02 KB

>1 month without response. I'm going to assume this is good enough.

Also attaching a patch for D7.

  • Wim Leers committed 5771d48 on 8.x-3.x
    Issue #2874178 by Wim Leers: Update README to warn that when using...

  • Wim Leers committed 2b2042f on 7.x-2.x
    Issue #2874178 by Wim Leers: Update README to warn that when using...
Wim Leers’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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