Which approach do you recommend to make your JSP project / Spring MVC project ready for a Content Delivery Network (CDN)?
Meaning: On localhost static contents should be local, on live website static contents should be delivered by CDN.
At moment I see only following options:
- Use an environment property e.g.
<img src="${env.resourceUrl}/mypath/pic.jpg" />
- Use an customized tag
<custom:img src="/mypath/pic.jpg" />
which appends the CDN host name on demand - Append CDN host name on client-side using JQuery (bad practice?) e.g.
$("img").each(function() { this.src = 'http://HOSTNAME/' + src; });
or$("img").attr('src', function(index, attr) { this.attr = 'http://HOSTNAME/' + this.attr; });
Any ideas? All suggestions are welcome :-)