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)
没有评论:
发表评论