2010年1月2日星期六

Re: [fw-mvc] BaseUrl and subdomains

My choice would be to serve all static content from static.mydomain.tld/whatever and then use a proper load balancing solution external to the application if and when it is needed.

However, you could also use logic within the baseUrl() helper. For example, all js and css from CDN1, all images from CDN2 and all video from CND3.

The added benefit from keeping all that logic inside baseUrl(), is that you can change your mind, and you dont have to rewrite a load of view scripts.

Paul

On 31 Dec 2009, at 00:40, Bill Chmura wrote:

>
> Interesting.
>
> How would I split up the requests in this case? Part of what the CDN1, CDN2, CDN3 did was to make sure the same image or resource got the same static server each time (for caching - each one points somewhere different)... I suppose I could pass that in here but seems like extra work on the server for no real gain, at least in my case.
>
> Thanks for any info
>
> On 12/30/09 5:30 AM, Paul Court wrote:
>> Hi Cristian,
>>
>>
>> On Tue, Dec 29, 2009 at 10:51 AM, Cristian Bichis<contact@zftutorials.com> 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).
>>>
>>
>> I will second Hector's suggestion...
>>
>> On 29 Dec 2009, at 19:03, Hector Virgen wrote:
>>
>>
>>> I'd probably go with a custom view helper to keep from polluting the router with a server name that only applies to static resources.
>>>
>>> --
>>> Hector
>>>
>> This way you are keeping all the logic for your CDN or whatever inside your baseUrl() helper. I use an extra parameter to signify if the resource is static or not, like this:-
>>
>> <?php
>> class Zend_View_Helper_BaseUrl {
>>
>> public function baseUrl($static = false) {
>> $fc = Zend_Controller_Front::getInstance();
>> return $fc->getBaseUrl();
>> }
>> }
>> ?>
>>
>> As you can see, at the moment it is just a standard baseUrl helper, but in the future I can change this block of code and modify the behaviour anyway I want without having to change anything else (unlike Bill's solution, which has CDN1,2,3 all over his view scripts!).
>>
>> Regards
>> Paul
>> (aka. Gargoyle on #zftalk)
>>
>>
>>
>

没有评论: