Pergunta

For performance reasons, I want to deliver some of my files from 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) }}
Foi útil?

Solução

in in config.yml just add something like:

framework:
    templating:
      engines: ['twig']
      assets_base_urls:
        http: [http://yourcdn.com]

Outras dicas

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).

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top