Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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 ?
Comment | File | Size | Author |
---|---|---|---|
#23 | 2874178-22-D7.patch | 1.02 KB | Wim Leers |
#22 | 2874178-22.patch | 1.02 KB | Wim Leers |
Comments
Comment #1
Anonymous (not verified) CreditAttribution: Anonymous commentedhanser created an issue. See original summary.
Comment #2
Wim LeersThe 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.Comment #3
Anonymous (not verified) CreditAttribution: Anonymous commentedThe 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
Comment #4
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #5
Wim LeersYou didn't answer my question.
Comment #6
Anonymous (not verified) CreditAttribution: Anonymous commentedThanks 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?
Comment #7
Wim LeersWhere in the HTML does it point to that file?
Comment #8
Anonymous (not verified) CreditAttribution: Anonymous commentedNever, 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">
Comment #9
Wim LeersIf #8 is true, then this
does not make any sense.
Comment #10
Anonymous (not verified) CreditAttribution: Anonymous commentedYeah, 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 ?
Comment #11
Wim LeersNo, 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.
Comment #12
Anonymous (not verified) CreditAttribution: Anonymous commentedThanks.
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)
Comment #13
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #14
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #15
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #16
Wim LeersI've yet to see one that does not. All CDNs I know of do this by default IIRC. Which CDN are you using?
As much as I hate
?itok=…
, that's a dangerous recommendation.Comment #17
Anonymous (not verified) CreditAttribution: Anonymous commentedHi 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.
Yeah, it's true, i just mentioned it for completeness of information.
Comment #18
Wim LeersOkay, so let's update the docs and point to http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/QueryS....
Comment #19
Wim LeersComment #20
Wim LeersThis also affects the Drupal 8 version of the CDN module.
Comment #21
Wim LeersComment #22
Wim LeersComment #23
Wim Leers>1 month without response. I'm going to assume this is good enough.
Also attaching a patch for D7.
Comment #26
Wim Leers