Serving the GWT files from a CDN?

350 views
Skip to first unread message

Dobes

unread,
Nov 17, 2009, 11:50:25 PM11/17/09
to Google Web Toolkit
I'm looking to improve load times for our application (and our site)
and I think a CDN (like SimpleCDN or something) could be really
helpful. For example, serve the js code from cdn.mydomain.com and run
the RPC servlet from api.mydomain.com.

Has anyone tried using a CDN with GWT modules?

I've heard that in javascript you can do something like
document.domain = 'mydomain.com' and this would allow you to treat all
subdomains of mydomain.com as the same domain with respect to the same-
origin-policy. Would I be able to run document.domain='mydomain.com'
in my onModuleLoad() using JSNI and gain the ability to access an RPC
servlet at api.mydomain.com if the GWT code was served from
cdn.mydomain.com ?

Based on what I read in Issue 214 ( http://code.google.com/p/google-web-toolkit/issues/detail?id=214
) the cross-site linker should also make this possible by using js
files instead of an html iframe, so the js operates in the same domain
as the host page instead of the domain of the *.cache.html file.
However, the continued existence of the "std" linker seems to imply
that there must be some drawback to using the cross-site linker. Any
ideas what that disavantages of the cross-site linker might be?

Thanks,
Dobes

Sripathi Krishnan

unread,
Nov 18, 2009, 12:18:44 AM11/18/09
to google-we...@googlegroups.com
A CDN doesn't require you to setup a different domain for your static content. It should be able to serve static content, and proxy RPC requests to your server (typically called origin).

In short, you shouldn't have to change your gwt code at all to get it working with a CDN.

--Sri


2009/11/18 Dobes <dob...@gmail.com>

--

You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=.



lowecg2004

unread,
Nov 18, 2009, 5:18:46 AM11/18/09
to Google Web Toolkit
It's definitely possible to serve GWT static assets from a CDN, see
comments from an earlier discussion:

http://groups.google.com/group/google-web-toolkit/browse_thread/thread/92ec90538cb4453a/a4dfe85c81c2e8ce?q=#a4dfe85c81c2e8ce

I've not tried the JS technique you describe nor have I used the
proxying technique described by Sri. I just used a subdomain for my
static assets which is served from the CDN. Then I served the webpage
that hosts the GWT app from the same place serving RPC to satisfy Same
Origin Policy (SOP).

Good luck,

C.


On Nov 18, 4:50 am, Dobes <dob...@gmail.com> wrote:
> I'm looking to improve load times for our application (and our site)
> and I think a CDN (like SimpleCDN or something) could be really
> helpful. For example, serve the js code from cdn.mydomain.com and run
> the RPC servlet from api.mydomain.com.
>
> Has anyone tried using a CDN with GWT modules?
>
> I've heard that in javascript you can do something like
> document.domain = 'mydomain.com' and this would allow you to treat all
> subdomains of mydomain.com as the same domain with respect to the same-
> origin-policy.  Would I be able to run document.domain='mydomain.com'
> in my onModuleLoad() using JSNI and gain the ability to access an RPC
> servlet at api.mydomain.com if the GWT code was served from
> cdn.mydomain.com ?
>
> Based on what I read in Issue 214 (http://code.google.com/p/google-web-toolkit/issues/detail?id=214
Reply all
Reply to author
Forward
0 new messages