Let me clarify that I set the CDN in my .htaccess file for each site. The index.php or bootstrap grabs them and sets the constants, and if they are not there it does set a default.
On 12/30/09 12:27 AM, Bill Chmura wrote:
Hi Cristian,
I am somewhat new to ZF, so I am not sure I know why you are doing all that... If you are just doing the static web stuff, just code for the url... One of our projects I defined some environmental variables for CDN1, CDN2, CDN3 and set them to different locations. My bootstrap checks for them and if they are not there they get set to basically "".
All my references to anything are like
<td background="<?=CDN1?>/styles/images/bg_t0_rightfade.jpg" width="375" valign="top">
So during development and testing they can go to one place, then in production the CDN1, etc get set to our Amazon content delivery domains. I do CDN1, CDN2, CDN3 so the browser will do more at once, and in theory render the page faster. Some browsers will only start 10 connections to a single domain I've read, so this allows us to get 30 going quickly. The constant also allows us to be flexible. I suppose you could do them based on what resource they were... Heavy stuff moved off site perhaps... It also works if your traffic goes way up... you can route images from a server that does not do cookies or php, something light and fast.
So we sort of round-robin them when assigning them. If the CDN is blank, then it just goes to the root of the site its currently running from.
Like I said, I am somewhat new to this, but a constant in there seems a bit less complicated than messing with the controller...
I don't know if that helps - but if its crazy, I'd also like to hear about it :)
Bill
On 12/29/09 1:51 PM, Cristian Bichis wrote:Hi,
I have one small problem while working on a ZF based website.
The website is supposed to work on www.domain.com and some of the parts are working on subdomains as subdomain1.domain.com, subdomain2.domain.com, aso.
I want to load the static resources (js, css, images) from the main domain, and not from the subdomains, because are the same, for both domain and subdomains. Purpose is obvious: to have the static resources loading from one single location, so it would cache (so everything load faster, no matter on which subdomain we are).
Now: so the resources are loaded from the www.domain.com i'we set the base Url to:
resources.frontcontroller.baseUrl = "http://www.domain.com/"
And the resources are loaded from one location (sample: http://www.domain.com/images/img1.png), no matter on what subdomain we are... Great...
But there is one problem: seems all the requests for URL's (pages, not static content) are now dispatched to module=default, controller=index, action=index...
As far as i checked the problem is the baseUrl is used also at dispatch.
I have found some workarounds:
1. Use my own helper to point all static resources to the www.domain.com
2. Into a preDispatch i set the baseUrl to http://www.domain.com/
Both solutions are fine, but i am wondering if there is one more elegant solution...
-- Best regards, Cristian Bichis www.zftutorials.com | www.zfforums.com | www.zftalk.com | www.zflinks.com
没有评论:
发表评论