Forum Discussion
Hi Andrew,
Thank you very much for your answer!
I was using the webUI function to get the static links of my assets:
<img src='${webUi.toStaticAssetUrl("/t5/image/serverpage/image-id/9787i2E014C1E5064A9BF")}' />
What is the difference with ${asset.get("/html/image.jpg")} and should I replace all my "webUI.toStaticAssetUrl" by "asset.get"?
Should I also use that function in the CSS and in the wrapper (js files in the header) of the community? (It seems to me that all links in the CSS file are already converted to static links, but not in the wrapper.)
Here is an example of what I get with Google Page Speed:
Leverage browser caching
- http://groupecasino.i.lithium.com/html/assets/cvous_background.png (expiration not specified)
- http://www.cvous.com/html/assets/cvous.config.js (expiration not specified)
There is one asset for which I used "webUI.toStaticAssetUrl" and the other one for which I didn't (I will correct that). The link are thus different. But in both cases, the tool says that no expiry date is specified. Any idea on that?
Thanks for the help!
Henrik
Hi Henrik,
With regard to the webUi context object and using it for URLs, that method is deprecated in favor of asset.get. I don't know the precise details on the differences between the two, but asset.get is the new best practice for static asset URLs. I would suggest switching all of your cases over to use the new method whenever you get a chance.
About adjusting URLs to use the CDN -- cache optimization is one way to get better end user performance, and using a CDN is another way. Our CDNs send the same cache headers that we send, so switching to the CDN will not help with the browser cache. But what it will do is reduce load on the community (which has the potential to improve overall experience for all users), and it will also let users download more assets faster, from servers close to their location (edge servers).
As I mentioned, we have different expiry behavior for different types of assets. For this situation where you are seeing an "Expires" header missing, this may be a case where we can improve. I encourage you to submit an idea to our product idea exchange because this would be a good feature enhancement for performance.
- Henrik12 years agoAdvisor