We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 49084
    • 3 Posts
    Hi all,

    Attempting to accomplish the simple task of serving all images, css and js via Amazon Cloudfront. This is working fine in the most part but I am having to manually prepend the links in the template chunks with the cloudfront domain. For example a link to image in the html is ...

    'assets/images/myimage.jpg'

    and I need this converted to..

    'http://cloudfront.mydomain.com/assets/images/myimage.jpg'

    My setup as follows (carried out in this manner so I don't need to upload images etc. to different server...

    1. Setup a subdomain on my modx server which can access only the assets directory --> assets.mydomain.com

    2. Created a cloudfront distribution with the origin = assets.mydomain.com and the cloudfront domain is cloudfront.mydomain.com.

    As the origin server is in fact the modx filemanager I don't need any form of validation to check that the file is present on the cdn. If I make changes I either change the filename of the image or css or use query string so I don't need to invalidate the cache.

    3. To get this working as a test I have manually changed some of my links in the template and all works fine pulling content from the CDN. However, this obviously will not work with images used in the content.

    Any ideas? Surely this can be accomplished with a change to a modx variable?

    If you're wondering why I don't use MaxCDN which sounds so simple.. 1. More expensive for the usage I expect on this site, 2. Cloudfront has far more edge locations near us (Europe).

    Thanks in advance.