Using Cloudfront To Mirror Symfony2 Assets

No need to dump your assets on S3 for easy caching!

instead of trying to dump assets in S3 - hard (links) - problems (links)

dump them on your server so they will be available throught URLs like this:

http://myapp.com/bundles/myapp/images/foo.png

but in your

# config.yml
templating:
    assets_base_urls: http://cdn.myapp.com
# config_dev.yml
templating:
    assets_base_urls: ~

so the HTML generated by twig will be

http://cdn.myapp.com/bundles/myapp/images/foo.png

then create a new CloudFront distribution with origin myapp.com that would be something like xxxxxxxxx.cloudfront.com and create the CNAME cdn.myapp.com -> xxxxxxxxx.cloudfront.com

As assetic uses Symfony2's asset system, it will work for them as well. You will get something like

<link rel="stylesheet" href="http://cdn.myapp.com/style.css" />
``
Quentin Pleplé
May 2014