I regularly use YSlow and google's pagespeed to do some basic performance checks of my website. I am new to Angular2 and recently have been working on an Angular2 project, I ran the YSlow and PageSpeed test on my Angular2 application.
PageSpeed did not run and YSlow gave a few suggestions to improve. As per these suggestions, I should add expiry header on the following js files -
inline.bundle.js
styles.bundle.js
main.bundle.js
vendor.bundle.js
What is the best/most efficient way of doing this in Angular2?
Also, as per another suggestion from YSlow I should also compress the same above resources coming from the server. How to enable compression in my local machine when I am using Angular-CLI and ng-serve to build?
Your concerns are about server setup, not the angular itself. Simply don't do them when you
ng serve. It will just slow down your development. I do my tests when I build production version of an appng b -prod -aot, and you can serve fromdist/folder to check stuff before deploying.Here's simple way that doesn't affect CLI
npm install --save-dev express compression connect-history-api-fallbackadd this express.js to your project root:
and run it after build with
node express.jsto verify production version is working and see compression in action.