Just optimized my site

Today I was trying to see if I can get a 100% score with Google Page speed. I started with a score of 65 out of 100. Now it’s time to quit, I achieved a score of 98%.

Most important changes to upgrade my score:

  • Configured expire headers and GZIP compression in IIS
  • Minified the Javascripts and CSS stylesheets
  • Moved static images to CSS as embedded base64 (used tool: web essentials extension). So less http requests!
  • Put javascript at the bottom of html as much as possible
  • Made favicon cacheable (http://www.guusbeltman.nl/FavIcon.ashx)
  • Used a HttpModule for cleaning up HTML (no comments, spaces, etc) A downloaded PageOptimiser source code and extended it to my needs.
  • Added a Google Analytics handler for a far-future expire date. GA Trick is described by Mads Kristensen.
  • Used Google CDN for jQuery and CDNJS

Tech Days 2013 NL – Day 2

I started the 2nd day of the Microsoft Tech Days with a level 400 session.

Hugo Kornelis – T-SQL User-defined functions

Hugo showed us why T-SQL User defined functions can be catastrophic for our database performance by demonstration it with live examples (he had 7 slides in his presentation deck!). With the statement:


You can see how many read/writes each table receives and how the SQL optimizer does clever things behind the scenes. Example: removing joined tables from the execution when it isn’t part/effects of the result.

Facts that I remembered
  • Query plan must be read from right to left (already knew that, but not everybody does).
  • User-defined functions are a black box for the SQL optimizer. This can affect the actual query plan.
  • Estimated query plan doesn’t show the actual reads/writes when UDF is involved
  • Table valued user defined function returns a table are better for the optimizer (no scalar value), but doesn’t solve the duplicate code issue.
  • Inline table valued user defined functions delivers statistics to the SQL optimizer. From a conceptional point of view this is actually a parameterized view (=macro). This delivers the performance you need, but can be hard to write. You need statements with CROSS APPLY.
  • Not actually part of the topic: COALESCE(..expression..) is the better version of the ISNULL(..expression...) function.
Relevant links

Mads Kristensen – Creating Visual Studio Extensions

Bart de Smet session was cancelled, so this session was a last-minute addition to the conference. There were a few reasons to go here:

  1. There are not a lot of session about this topic (and thorough documentation is not available).
  2. Mads is the founding father of the Web Essentials extension, this session should be interesting.
Developing extensions

He showed that almost everything is possible to extend. It’s only sometimes difficult to find out ‘how’. Creating extensions is mostly done by ‘Search Driven Development’. So use Google to find the info you need to complete your code. One of the reasons is the use of magic strings that are used for hooks in VS.

For extensions you need the Microsoft Visual Studio 2012 SDK. After you installed the VS2012 SDK you get extra extensibility project templates. Most of the times the ‘package’ template is best.

Testing and debugging

To test and debug your extension you just can press F5 then the Experimental Instance of Visual Studio will be launched as a testing container. This special version of VS has it’s own registry settings, so it doesn’t conflict with your normal version.

The VSIX package

A .vsix is just a zip file, so you can rename it and view the contents. Strangest thing is that VS doesn’t compress the package. So if you like to release a smaller package you best can: 

  1. Rename to .ZIP
  2. Extract the files
  3. Rezip the files
  4. Rename to .VSIX

Note to self: try this stuff at home!

Relevant links


Alan Smith – Web Site Authentication with Social Indentity Providers

The session from Alan Smith was mainly about ACS: Azure Control Service. Microsoft is supporting multiple identity providers: Google, Yahoo, Facebook and LiveID accounts. All providers supports only the name identifier claim (which is unique and immutable). Only Google and Yahoo also deliver the name and email address as extra claims.

Steps within the ACS portal:

  1. Register the application (should match the realm)
  2. Define the rule and claims
  3. Add federation to the Asp.net project (think about setting the certificate validation to Off in the web.config of you development environment).
  4. Protect the resources with security settings in the web.config
Small notes

- Security token = set of claims + encryption (optional) + signed

- Within ACS it’s possible to define extra Role Claims.

- Relying party should trust the identity provider

Blog of the Alan Smiths

Cross Platform Mobile Application Development met Xamarin and T4

Presentation was given by three developers of Avanade. There were no real demo’s, only some code on slides. This is a bit disappointing, it’s a developer conference!

Things that I remembered
  • Targets on iOS, Android, WinRT (all phone and tablets). See screenshot example application.
  • Mvvm Cross goal = 80% reusable .NET code for all platforms
  • Makes use of Portable Class Library (1 assembly per platform)
  • Mvvm Cross delivers IoC, plugins, converters and more..
  • Uses T4 for generating code based on Views in XML
  • Mvvm Cross – Views are platform specific
  • Still need account for all stores (Windows Marketplace = 99 USD per year, Android Play Store = 25 USD per app, Apple iStore = 99 USD per year).
  • Xamarin is a commercial product. Single developer is 299 USD. See pricing for more.
  • Avanade created their on layer on top of Mvvm cross, called Tea Light.
  • Visual Studio has no coding assistence for T4. Avanade developers recommended Tangible T4 Editor. This is also a commercial product.

Tip: for testing on mobile devices can be done in the cloud by using PerfectoMobile.com


Jeff Prosise – HTML 5: The Good, the bad, and everything in between

HTML5small Jeff presentation was covering misc. HTML5 features with a lot of demo’s. He provided each HTML5 feature with a Grade (A to F) and explained us why with Pro’s and Con’s which was nice!

See the video, it says it all..

Relevant links

Tech Days 2013 NL – Day 1

techdayslogo The Microsoft Tech Days were held in the Hague and are two days of developer fun. My employer was so friendly to let me attend the conference. This year there were no real new products or major updates to notice. This left space for more niche sessions about mobile development and some IT pro presentations.

I’ll try to sum up the visited sessions and the online documentation I found later. I tried to pick sessions I am not really familiar with and where I can learn the most.

Sadly I missed the keynotes like a lot other people due to traffic jams. But the recordings are already online: http://channel9.msdn.com/Events/TechDays/Techdays-2013-the-Netherlands

Ben Riga – Building world-ready Windows Store apps with HTML/CSS/Javascript.

I was planning to go to Philip Japikse session (found no recording!!) about ‘Slice development time with ASP.NET MVC’, but it’s was completely full. (Why are the most popular sessions in the smallest rooms?)

One of the things that Ben Showed us was how to localize your app for multiple languages. He demonstrated the use of the Multilingual app toolkit to do an initial translation with the help of the Bing Translation service. Very nice & easy! Note: this translation should be reviewed before publishing your app to the store.

Relevant links:

Alex van Beek – Entity Framework 5 & 6: de stand van zaken

Alex took us through the history of Entity Framework. Version 1 (which was not really good), 4, 4.1, 4.2 and 5. The last part of his session was about the alpha 3 version of Entity Framework version 6 , is also available on NuGet.

Things that I remembered:

  • E.F. version 1 is declared as a bad product since it was not usable in production environment
  • E.F. version 4 is a giant leap, that’s why version 2 & 3 were skipped

E.F. version 5 has notable features:

  • DbContext is a wrapper around ObjectContext object. General complaint about ObjectContext object that it contained too much detailed feature that were not commonly used. DbContext is more straight forward in use and you still can use ObjectContext if want to have more advanced features.
  • Multiple diagrams per model (in other words: support for big database modelling)
  • Coloring of shapes on the design surface (Shiny!)
  • Batch import of stored procedures.
  • Enum support (Best practice, explicitly assign a integer to enum values)
  • Table-valued functions support
  • Spatial data types (Can be useful when you’re creating mobile apps with GEO features). Alex showed us a demo to calculate which addresses where within 20 kilometers of the city Veenendaal within(!) a SQL query. Nice!

E.F. version 6 has these planned features:

Tip: Download the E.F. Powertools extension. (You can reverse engineer your database to code. Only adviced to be used for small database, since you can’t select the tables you want.)

Relevant links:

Arie Leeuwesteijn – Async and parallel patterns and application design

Arie talked about C# 5.0 async features, Reactive Extensions, Task Parallel Library and TPL Dataflow. He described the need of parallel computing and the new await and async statements. I don’t have taken notes, so here are some links:

Mads Kristensen – Beyond Visual Studio 2012: What’s coming for Web Developers

Mads Kristensen presented a nice session about Visual Studio being a good IDE also for web developers. His Web Essentials extension contains a lot of features that makes their lives much easier.

Mads demonstrated the Page Inspector feature. Within Visual Studio you get a inline browser window where you can inspect a element that traces back to the .CS sourcecode (Like a HTML developer would do with Chrome Dev Tools). Other highlights of P.I.:

  • Review the javascript callstack (very useful for debugging KnockOut enabled pages)
  • Live and real time CSS editing (with/without saving the actual file).
  • Intellisense for KnockOut Mvvm model

He should also the awesome magic of Zen Coding. Example in html template: ul>li*5>a -tab-tab-. This will create a list with 5 anchor tags.

Another useful extension is the Image Optimizer. This tool combines SmushIt and PunyPNG for optimizing the images.

You should see the recording, Mads had a great talk.

Relevant links: