While performance testing an Angular.js website, I ran the site through a few benchmarking tools like Google PageSpeed Insights, Yahoo’s YSlow, and so on…
One of the recommendations that these tools returned is ‘Serve static content from a cookieless domain’. Although there is some discussion going on if this recommendation actually makes sense, I spend some time reconfiguring IIS to get this working so I can measure the impact myself.
Here are the steps I took to get it working:
- Inside IIS I configured 2 websites:
- A Default Web Site that listens on port 80 and has a custom host header configured(I used www.test.com as an example)
- A second website CDN that also listens on port 80 and has a different custom header configured(I used cdn.test.com for this one)
- For the CDN site, disable ASP.NET session state, this prevents cookies from being returned by ASP.NET.
- Click on Session State.
- Set the Session State Mode on Not enabled and click on Apply.
- Copy your static content(images, css, javascript) over to the CDN site
- Inside your website, change the urls for the static content to point to the CDN site.
- Run your application
- If you look at the requests to the default website, you see that cookies are sent with the request:
- But if we look at a request to the CDN, no cookies are included: