Domain name aliases cause problems for nowjs file caching

45 views
Skip to first unread message

Richard Rodger

unread,
Jun 5, 2011, 8:43:14 AM6/5/11
to nowjs
Hi Guys,

I've come across a problem where the site I am using nowjs on can be
reach from www.example.com and example.com

Depending on which domain alias is used randomly by clients after a
restart, nowjs "fixes" on the domain alias in fileServer.js, and
requests to the other domain don't work - because the cached files are
returned and fall afoul of the cross-domain restriction.

My fix was to redirect all clients to a canonical domain - is this the
right approach?

thanks,
Richard

Tom

unread,
Jun 5, 2011, 9:29:31 AM6/5/11
to no...@googlegroups.com
The following is slightly related, but not an answer to your question.

From a SEO point of view you would gain from 303ing all requests from the www subdomain to the root or the other way around. www is considered to be a subdomain and if you adhere to both you may be penalized as people will link to the same pages in different ways.

For example, twitter redirects all requests to http://www.twitter.com to http://twitter.com (but this could also be done the other way around.

Tom

2011/6/5 Richard Rodger <ric...@chartaca.com>

Eric Zhang

unread,
Jun 5, 2011, 1:16:10 PM6/5/11
to no...@googlegroups.com
So according to Tom it seems that redirecting clients to a canonical domain is the solution because it benefits you SEO wise.


One note is the cached files in your case should still work as cross-domain and port requests are fully supported with WebSockets, and jsonp-polling. If you use the insecure version of the flashsockets swf then you can get flashsockets to also work crossdomain/port. 

Of course that is not optimal when you can have things not be cross-domain but it shouldn't be not working at all. (Detecting whether the connection should be cross-domain or not is determined at runtime so it's not a problem that cached files are originally set when not-cross-domain but then used in cross-domain context)

Wow ok that was a mouthful. Good luck!

Eric

Tom

unread,
Jun 5, 2011, 1:20:02 PM6/5/11
to no...@googlegroups.com
On another side note Facebook seems to redirect all requests to http://facebook.com to http://www.facebook.com -- so if you're going this road, it comes down to a matter of preference on whether you keep www or not. One argument to keep it would be that many users believe that the www prefix is mandatory in accessing a site, so that they might feel more comfortable by actually seeing this 'www' back in the address bar.

Admittedly this does not have much to do with solving your problem. Sorry I cannot help you further.

Tom

2011/6/5 Eric Zhang <er...@nowjs.com>

Sridatta Thatipamala

unread,
Jun 5, 2011, 1:27:30 PM6/5/11
to no...@googlegroups.com
Hmm, I don't know why NowJS would fix on a particular domain. File
caching/hosting for multiple domains was enabled in this pull request.
https://github.com/Flotype/now/pull/85

It should serve the appropriate version of the file based on what
domain the client appears to be using.

Eric Zhang

unread,
Jun 5, 2011, 1:33:37 PM6/5/11
to no...@googlegroups.com
Hmm I wonder if request.headers.host ignores the subdomain (www.)? That would explain it but otherwise I'm surprised too. (I forgot about that commit before Sri mentioned it)


Eric
Reply all
Reply to author
Forward
0 new messages