Re: How to configure domain alias.

208 views
Skip to first unread message

Joshua Marantz

unread,
Nov 3, 2012, 12:03:59 PM11/3/12
to mod-pagespeed-discuss
It looks like you have outline_css enabled.  Do you have multiple Apache servers?  If so, you will need to disable outline_css (and outline_javascript if you have that).  That limitation can be relaxed with our next release which will support memcached, allowing two servers to share a server-side cache.

RE "cached separately": mod_pagespeed will not cache origin resources if LoadFromFile is enabled.  However, it will cache rewritten resources based on the full URL, so if you have foo.css it will wind up being cached twice in both the browser & server-side cache.  You can resolve that issue with:
   ModPagespeedMapRewriteDomain http://www.mydomain.com http://www.alias.mydomain.com

-Josh


On Sat, Nov 3, 2012 at 11:37 AM, Joyce Babu <jo...@joycebabu.com> wrote:
I have two domains mydomain.com and alias.mydomain.com. alias.mydomain.com is nothing, but a CNAME to mydomain.com. All public requests will be served through, mydomain.com.

How do I configure this properly so that the optimized files won't be cached separately?

Currently I am using the following configuration

ModPagespeedDomain www.mydomain.com
ModPagespeedDomain www.alias.mydomain.com

ModPagespeedLoadFromFile "http://www.mydomain.com/" "/var/www/vhosts/username/public_html/"
ModPagespeedLoadFromFile "http://alias.mydomain.com/" "/var/www/vhosts/username/public_html/"

But this is not working as expected. It works correctly for most of the files, but for some file it gives a 404 error. For example, a file www.mydomain.com/entertainment/I._,Mco.Gkw7JDe1yd.css.pagespeed.cf.oN5k-hjpgQ.css is giving a 404 error, when accessed as alias.mydomain.com/entertainment/I._,Mco.Gkw7JDe1yd.css.pagespeed.cf.oN5k-hjpgQ.css

Joshua Marantz

unread,
Nov 5, 2012, 7:13:33 AM11/5/12
to mod-pagespeed-discuss
ModPagespeedMapRewriteDomain affects the URLs that are written into HTML files for link, img, and script tags, plus the URLs written into CSS files for background images.

ModPagespeedMapOriginDomain affects the way mod_pagespeed internally requests css, image, and js files.

So when you say "I want mod_pagespeed to rewrite requests" it sounds to me like you are talking about the URLs written into HTML/CSS files, not the way mod_pagespeed itself fetches the results.  Thus my suggestion of ModPagespeedMapRewriteDomain.

-Josh


On Mon, Nov 5, 2012 at 3:26 AM, Joyce Babu <jo...@joycebabu.com> wrote:
Yes, I have outline_css and outline_javascript filters enabled. Fortunately, there is only one Apache server.

I am not sure if ModPagespeedMapRewriteDomain will help me here. As mentioned in one of the other discussions, I am using EdgeCast as an origin pull CDN for my static resources. It is very difficult to prevent origin pull CDN from serving HTML content, and this causes duplicate content issue. I was using a long list of mod_rewrite rules to block EdgeCast IP addresses from accessing HTML files. It is difficult to keep the IP addresses up to date.

I am now trying a different configuration, where alias.mydomain.com (which is a ServerAlias of mydomain.com) is set as the CDN origin at EdgeCast. Now I can detect all requests from the CDN by checking the HTTP_HOST variable. alias.mydomain.com will be used only by the CDN, and it will not appear in HTML code served to users.

When a user visit a page, the outlined CSS get rewritten as

When the browser requests the CDN for the file, it will contact the origin for the file

So, I want mod_pagespeed to rewrite requests for alias.mydomain.com/* to mydomain.com/*. Should I use ModPagespeedMapRewriteDomain or ModPagespeedMapOriginDomain for this?

Thanks,
Joyce

Joshua Marantz

unread,
Nov 5, 2012, 4:47:51 PM11/5/12
to mod-pagespeed-discuss
I see.  There are two problems:
   1. You are using ModPagespeedShardDomain for what ModPagespeedMapRewriteDomain is designed for.  Remove your shard directive and put in this:
            ModPagespeedMapRewriteDomain http://cdn.mydomain.com http://www.mydomain.com
       Note that the argument order is reversed; the domain you are mapping to is the first argument for that command.
   2. There is a performance bug in the current release.  It's already fixed and will released very soon (hopefully this week).  We have already cut the branch but we
       need to run all our platform & load tests.   The performance bug means that you will still (probably) get the duplicate cache entries but the product will function,
       and the duplicate entries will be fixed when you upgrade.

You can also remove the MapOriginDomain command that you have: you are covered by LoadFromFile.  The MapOriginDomain won't matter.

-Josh



On Mon, Nov 5, 2012 at 8:22 AM, Joyce Babu <jo...@joycebabu.com> wrote:
Sorry for the confusion. I was actually referring to mapping requests for alias.mydomain.com to mydomain.com. Mod_pagespeed rewrites www.mydomain.com/request-file-path to cdn.mydomain.com/request-file-path (due to ModPagespeedShardDomain directive). cdn.mydomain.com is an origin pull CDN. It will pull the file from the origin ( alias.mydomain.com/request-file-path ). Currently, mod_pagespeed does not know that www.mydomain.com, cdn.mydomain.com and alias.mydomain.com are all serving the same content. Hence, it will create duplicate copies of the optimized resource under

/var/www/mod_pagespeed/cache/http,3A/,2Falias.mydomain.com
/var/www/mod_pagespeed/cache/http,3A/,2Fcdn.mydomain.com

Is it possible to inform mod_pagespeed that alias.mydomain.com and cdn.mydomain.com are same, hence it should map requests for resources under alias.mydomain.com to cdn.mydomain.com? It should use the existing cached file under /var/www/mod_pagespeed/cache/http,3A/,2Fcdn.mydomain.com rather than creating a new file at /var/www/mod_pagespeed/cache/http,3A/,2Falias.mydomain.com.


According to https://developers.google.com/speed/docs/mod_pagespeed/https_support , I cannot use ModPagespeedMapOriginDomain along with ModPagespeedLoadFromFile. So, if I use the following configuration
ModPagespeedDomain www.mydomain.com
ModPagespeedDomain alias.mydomain.com

ModPagespeedMapOriginDomain http://www.mydomain.com http://alias.mydomain.com

ModPagespeedLoadFromFile "http://www.mydomain.com/" "/var/www/vhosts/username/public_html/"
ModPagespeedLoadFromFile "http://alias.mydomain.com/" "/var/www/vhosts/username/public_html/"

Should I remove the ModPagespeedLoadFromFile directive? If so, will mod_pagespeed automatically map the domain alias.mydomain.com to the file system path /var/www/vhosts/username/public_html/, or will it make HTTP requests for fetching the files?
Reply all
Reply to author
Forward
0 new messages