Referencing assets from a CDN using the acs.commons.rewriter component



We want to use a CDN with our AEM project to serve up the assets (images, scripts, css), so I've configured the aem-commons rewriter component to reference the assets from a static domain.  I can see the rewriter in action, and the images are now being pulled from the static domain, but the images appear to be broken links. Now that I'm looking at this more closely, I can see in my browser inspector that AEM has renamed the images different from the source file, and they have been changed to a number string.  eg. What I would have expected to see is:

"<img src="/content/test/_jcr_content/par/image.img.png/banner-1.png>" 
but now I see

"<img src="/content/test/_jcr_content/par/image.img.png/1462897411261.png>".  

Obviously, if I upload my images to the CDN with their original names then the images will look broken on the site because the names are all wrong.

What is the best approach here?  Is there a way to download the DAM which will give me all of the assets with their AEM names, which I can then upload to the CDN?  Or is there a way to configure AEM to not rename the assets so they keep their original names (which incidentally are also their filenames in the DAM)?

Or is there another way to do this altogether that I haven't considered?


Accepted Solutions (1)

Accepted Solutions (1)



Thanks for the reply Mark.  Sorry for the tardy reply, but I thought I'd put some notes down here in case someone else runs into the same thing.

It turns out that the AEM image component was the culprit.  When using a resourceSuperType of 'wcm/foundation/components/image', AEM creates a bunch of renditions of your images - this is where the file naming went awry.  If I don't use the image resourceSuperType on my component then the renditions don't get created and my file name remains the same as the original file name.

For anyone else looking to use a static domain to host your images/assets, the ACS Static Reference Rewriter works great.

Answers (1)

Answers (1)




Hi Matt,

You may want to check over on to see if there is some issue

I am not familiar with the component you use but if you have content on Author and it is pushed to Publish nodes and works fine, then it doesn't matter what it is called (except for SEO / search)

But in general terms;

You don't upload content to a CDN - you set an origin hostname for your site and have your CDN configure that to pull from. Your site URL will be CNamed to the CDN provider's service. Your CDN partner will be able to advise here.

Found this article: