Twig asset with CDN using Symfony 2
For performance reasons, I want to deliver some of my files from开发者_Python百科 a CDN.
Is it possible to configure the "asset" helper such that it automaticly sets something like "static1.xxxx.com/css/main.css" and "static2.xxxx.com/css/main.css"?
Perhaps something like:
{{ asset('css/main.css',static1) }}
in in config.yml just add something like:
framework:
templating:
engines: ['twig']
assets_base_urls:
http: [http://yourcdn.com]
I think it is better to do something like:
templating:
packages:
cdn:
base_urls:
ssl: ['url']
http: ['url']
That way you can do things like asset('yourfile', 'cdn') and also have multiple cdns (by specifying more packages).
精彩评论